Initializing an Array As a Range or Sequence of Values: array range(mixed $start, mixed $end[, mixed $step]) : range « Utility Function « PHP






Initializing an Array As a Range or Sequence of Values: array range(mixed $start, mixed $end[, mixed $step])

 
<?php 
function array_list($array) { 
    printf("<p>(%s)</p>\n", implode(', ', $array) ); 
} 
$arr1 = range(5, 11); 
array_list($arr1); 
$arr2 = range(0, -5);
array_list($arr2); 
$arr3 = range(3, 15, 3);
array_list($arr3); 
array_list( range(20, 0, -5) ); 
array_list( range(2.4, 3.1, .1) ); 
array_list( range('a', 'f') ); 
array_list( range('M', 'A', -2) ); 

?>
  
  








Related examples in the same category

1.range( ) function creates an array of numbers between a low value and a high value.
2.range( ) function has a third parameter that allows you specify a step amount in the range.
3.If your low parameter (parameter one) is higher than your high parameter (parameter two), you get an array counting down, like this:
4.Use range( ) to create arrays of characters, like this: