Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

foreach loop

<?php

//use for printing arrays.

$x=array("Cat","Dog","Hen");

foreach($x as $value)
{
	echo $value."<br>";
}

//======output=====
/*
Cat
Dog
Hen
*/

foreach($x as $key => $value)
{
	echo $key."-".$value."<br>";
}
//======output=====
/*
0-Cat
1-Dog
2-Hen
*/
?>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #foreach #loop
ADD COMMENT
Topic
Name
7+5 =