jd2007 Posted August 16, 2007 Share Posted August 16, 2007 Can i use php to loop through two arrays the same time for example like in JavaScript ? for e.g. Link to comment https://forums.phpfreaks.com/topic/65219-can-i-use-php-to-loop-through-two-arrays-the-same-time-for-example-like-in-js/ Share on other sites More sharing options...
NArc0t1c Posted August 16, 2007 Share Posted August 16, 2007 How do you mean? <?php $ArrayOne = array('one','two','three'); $ArrayTwo = array('1','2','3'); echo 'Array One<br />'; foreach($ArrayOne as $Text){ echo $Text . '<br />'; } echo '<br />Array Two<br />'; foreach($ArrayTwo as $Numbers){ echo $Numbers . '<br />'; } ?> Link to comment https://forums.phpfreaks.com/topic/65219-can-i-use-php-to-loop-through-two-arrays-the-same-time-for-example-like-in-js/#findComment-325687 Share on other sites More sharing options...
jd2007 Posted August 16, 2007 Author Share Posted August 16, 2007 in javascript, it looks like this: for (i=0&&h=0; i<=20&&h<=30; i++&&h++) { document.write(i+"and"+h); } something equivalent to the above in php pls ? Link to comment https://forums.phpfreaks.com/topic/65219-can-i-use-php-to-loop-through-two-arrays-the-same-time-for-example-like-in-js/#findComment-325695 Share on other sites More sharing options...
ToonMariner Posted August 16, 2007 Share Posted August 16, 2007 yes the syntax is exactly the same in php http://uk.php.net/manual/en/control-structures.for.php look at example 4 Link to comment https://forums.phpfreaks.com/topic/65219-can-i-use-php-to-loop-through-two-arrays-the-same-time-for-example-like-in-js/#findComment-325722 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.