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 Quote 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? Quote 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 Quote 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? Quote Link to comment https://forums.phpfreaks.com/topic/68759-a-quick-question/#findComment-345619 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.