In Action

Php Toycode - Looping through a list (array)

Simple example demonstrating how to loop through a list using a php foreach loop. In Php the terms array and list mean the same thing. This example uses the ++ iterator.


forloop



Toycode

Php Code

Just cut-n-paste to reuse.

     
<?php
$fxarr = array("f", "u", "b", "a", "r");

$pos=1;
foreach($fxarr as $itm) 
{
	echo $pos++ . " " . $itm . "\n";
}
	
?>