//While loop <?php $myFam = array("Rose","Robert","Tia","Scean","Mateo"); while($myFam <= 4){ echo $myFam . ", "; $myFam++; } ?> //////////////////////////////////////////////////////////////////////////////////////////////////// //for loop <?php for($count = 0; $count <= 10; $count++){ echo $count . ", "; } ?> //////////////////////////////////////////////////////////////////////////////////////////////////// //foreach loop are only used on arrays <?php for($count = 0; $count <= 10; $count++){ echo $count . ", "; } ?> //////////////////////////////////////////////////////////////////////////////////////////////////// //This is an array with some data we want to modify when running through the for loop. $people = Array( Array('name' => 'Kalle', 'salt' => 856412), Array('name' => 'Pierre', 'salt' => 215863) ); for($i = 0; $i < sizeof($people); ++$i) { $people[$i]['salt'] = rand(000000, 999999); } |