PHP array printing using a loop


Question

If I know the length of an array, how do I print each of its values in a loop?

1
35
8/18/2009 2:41:31 PM

$array = array("Jonathan","Sampson");

foreach($array as $value) {
  print $value;
}

or

$length = count($array);
for ($i = 0; $i < $length; $i++) {
  print $array[$i];
}
99
8/18/2009 3:50:43 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon