timmah1 Posted December 8, 2008 Share Posted December 8, 2008 Can someone tell me why this only returns 1 row when there is actually 6 rows? foreach ($itemCodes as $fieldName => $val){ list($descr, $price) = explode("|", $val); $price = ($price == "N/A")? "N/A": sprintf("%.2f", $price); $products = array( array($price, $descr, '') ); } [/code I need it to display all 6 Thanks in advance Link to comment https://forums.phpfreaks.com/topic/136055-solved-for-each/ Share on other sites More sharing options...
Mchl Posted December 8, 2008 Share Posted December 8, 2008 Because you're overwriting $products variable in each pass? Link to comment https://forums.phpfreaks.com/topic/136055-solved-for-each/#findComment-709386 Share on other sites More sharing options...
timmah1 Posted December 8, 2008 Author Share Posted December 8, 2008 And how would I fix this? Link to comment https://forums.phpfreaks.com/topic/136055-solved-for-each/#findComment-709390 Share on other sites More sharing options...
Mchl Posted December 8, 2008 Share Posted December 8, 2008 $products[] = array($price, $descr, '') Link to comment https://forums.phpfreaks.com/topic/136055-solved-for-each/#findComment-709400 Share on other sites More sharing options...
timmah1 Posted December 8, 2008 Author Share Posted December 8, 2008 Thank you soooooo much!! Link to comment https://forums.phpfreaks.com/topic/136055-solved-for-each/#findComment-709402 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.