PHP – Access Array Values – Foreach()

The foreach() function allows you to loop though an array to process the values as variables.

<?php

$names = array('bob', 'tim', 'tom', 'shelly', 'julia');

foreach($names as $value) {
	print "$value </br>";
}
 
print "</br>";

sort($names);

foreach($names as $value) {
	print "$value </br>";
}
?> 


Be the first to comment

Leave a Reply