iPixel Posted October 21, 2009 Share Posted October 21, 2009 Ok, $branchid variable can hold values such as "5" and "5,23,6,3,40,9,14,18,33". So my though was, if i explode() $branchid, then $bID would automatically become and array of the branchid's by breaking it up through the "," seperator. Is my foreach bad? Why isnt this printing properly. My result is 33 for some reason instead of 5 23 6 3 40 9 14 18 33 Why does it pring just the last value? <?php $bID = explode(",", $branchid); foreach($bID as $key=> $value); { echo $bID[$key] . "<BR>"; } ?> Thanks! Link to comment https://forums.phpfreaks.com/topic/178476-solved-noob-foreach-question/ Share on other sites More sharing options...
Mchl Posted October 21, 2009 Share Posted October 21, 2009 Because you have an extra ; after foreach($bID as $key=> $value). So it basically loops the array doing nothing, and then echoes last element. Link to comment https://forums.phpfreaks.com/topic/178476-solved-noob-foreach-question/#findComment-941178 Share on other sites More sharing options...
iPixel Posted October 21, 2009 Author Share Posted October 21, 2009 HAHAHAHAH im so bloody blind! TY ! Link to comment https://forums.phpfreaks.com/topic/178476-solved-noob-foreach-question/#findComment-941179 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.