ballouta Posted February 27, 2009 Share Posted February 27, 2009 Hello, I am studying a sample application : Session Based shopping cart from a book. Actually I need to implement this code but with few changes. The sample supposes an exisiting file that contains the catalog data. e.g.: 101:AA Batteries (pack of 2) :2.99 etc... The code begins with looking for the catalog file and if found, it adds it to an associative array called $catalog. Then it prints the items: <?php foreach ($catalog as $k => $v) { ... echo "<b>" . $v['desc'] . "</b>"; echo "Price per unit:" . $catalog[$k]['price']; ... } Till here i do NOT need any of this code because my items are stored in a DB. But kindly i want to ask my first question then i post the others What is $K and $v? i mean how do they work here (foreach ($catalog as $k => $v))? thank you Link to comment https://forums.phpfreaks.com/topic/147136-session-based-shopping-cart/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.