phpretard Posted May 12, 2008 Share Posted May 12, 2008 This Code Only Displays One Array Value. Icant figure out where to put the $a++ if that is what I am Suppost to do. $a=0; foreach ($_SESSION as $lineItem => $val){ echo" <table border=1 width=100%> <tr> <td> ".$_SESSION[$lineItem][$a]['Item']." </td> </tr> </table>"; } Array ( [myusername] => Administrator [invoice_number] => 447425 [invoice_items] => Array ( [0] => Array ( [COName] => ENS Metals and Jewelry, Inc. [Cnumber] => 156882 [Price] => 226.97 [Quantity] => 100 [item] => Tri-Fold-Brochure [Description] => Full Color | Front And Back ) [1] => Array ( [COName] => ENS Metals and Jewelry, Inc. [Cnumber] => 156882 [Price] => 115.98 [Quantity] => 100 [item] => Rack-Cards [Description] => Inventory Sheet ) [2] => Array ( [COName] => ENS Metals and Jewelry, Inc. [Cnumber] => 156882 [Price] => 135.98 [Quantity] => 100 [item] => Flat-Invitation [Description] => Signature Cards ) [3] => Array ( [COName] => ENS Metals and Jewelry, Inc. [Cnumber] => 156882 [Price] => 175.98 [Quantity] => 100 [item] => Letterhead [Description] => Welcome Letter Standard Paper ) ) ) I need to display all of the ".$_SESSION[$lineItem][$a]['Item']." Any Help? Link to comment https://forums.phpfreaks.com/topic/105305-ive-almost-got-this-array-whipped/ Share on other sites More sharing options...
BlueSkyIS Posted May 12, 2008 Share Posted May 12, 2008 i think you want this.. foreach ($_SESSION['invoice_items'] as $item_values){ echo" <table border=1 width=100%> <tr> <td> {$item_values['Item']} </td> </tr> </table>"; } Link to comment https://forums.phpfreaks.com/topic/105305-ive-almost-got-this-array-whipped/#findComment-539261 Share on other sites More sharing options...
phpretard Posted May 12, 2008 Author Share Posted May 12, 2008 Sweeeeet! Just one more thingy. How do I display the [0] or the [1] etc... part of this: [0] => Array I think it's the $key but for the purpose of unseting peices of the array i need to identify that value. Link to comment https://forums.phpfreaks.com/topic/105305-ive-almost-got-this-array-whipped/#findComment-539266 Share on other sites More sharing options...
phpretard Posted May 12, 2008 Author Share Posted May 12, 2008 Maybe a better question would be how do I unset... [3] => Array ( [COName] => ENS Metals and Jewelry, Inc. [Cnumber] => 156882 [Price] => 175.98 [Quantity] => 100 [item] => Letterhead [Description] => Welcome Letter Standard Paper ) ...if I needed to. Link to comment https://forums.phpfreaks.com/topic/105305-ive-almost-got-this-array-whipped/#findComment-539276 Share on other sites More sharing options...
kenrbnsn Posted May 12, 2008 Share Posted May 12, 2008 If you use a for loop instead of a foreach loop, you have the index: <?php for($i=0;$i<count($_SESSION['invoice_items']);$i++) { echo" <table border=1 width=100%> <tr> <td> ".$_SESION['invoice_items'][$i]['Item']." </td> </tr> </table>"; ?> Ken Link to comment https://forums.phpfreaks.com/topic/105305-ive-almost-got-this-array-whipped/#findComment-539277 Share on other sites More sharing options...
phpretard Posted May 12, 2008 Author Share Posted May 12, 2008 That does't display anything (BTW i did see the "}" missing) Link to comment https://forums.phpfreaks.com/topic/105305-ive-almost-got-this-array-whipped/#findComment-539288 Share on other sites More sharing options...
kenrbnsn Posted May 12, 2008 Share Posted May 12, 2008 Did you see I misspelled $_SESSION as $_SESION? (flaky keyboard) Ken Link to comment https://forums.phpfreaks.com/topic/105305-ive-almost-got-this-array-whipped/#findComment-539307 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.