Iterating through Arrays:
$items = array('PHP', 'JavaScript','AJAX', 'Python','ASP', 'C#'); //iterate using foreach foreach($items as $val) { echo "$val"; } // iterate using for loop for($i = 0; $i < count($items); $i++) { print("$items[$i]\n"); }
Iterating through Associative Arrays:
$associative_array = array("a" => "Pizza", "b" => "Burgers", "c" => "Chips"); foreach ($associative_array as $key => $val) { print "$key = $val\n"; } while (list($key, $val) = each($associative_array)) { print "$key is $val\n"; }