dhimok Posted September 10, 2007 Share Posted September 10, 2007 A quick question: how do we print the values of this array in a for() loop $array[0] = 'a'; $array[1] = 'b'; $array[2] = 'c'; thanks Link to comment https://forums.phpfreaks.com/topic/68759-a-quick-question/ Share on other sites More sharing options...
Jessica Posted September 10, 2007 Share Posted September 10, 2007 Use a foreach(), or use a regular for loop. If you know how to echo/print, and you know how to use a for loop, what is the problem? Link to comment https://forums.phpfreaks.com/topic/68759-a-quick-question/#findComment-345613 Share on other sites More sharing options...
dhimok Posted September 10, 2007 Author Share Posted September 10, 2007 Normally i would use a foreach loop like foreach($array as $key => $value) { echo $value; } But in this situation is suitable to use for() loop Link to comment https://forums.phpfreaks.com/topic/68759-a-quick-question/#findComment-345614 Share on other sites More sharing options...
Daniel0 Posted September 10, 2007 Share Posted September 10, 2007 <?php for($i=0; $i<count($array); $i++) { echo $array[$i]; } ?> but why would you do that? Link to comment https://forums.phpfreaks.com/topic/68759-a-quick-question/#findComment-345619 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.