Mega Code Archive

 
Categories / Php / Functions
 

Range( ) function has a third parameter that allows you specify a step amount in the range

//array range ( mixed low, mixed high [, number step] ) <?     $questions = range(1, 10, 2);     // gives 1, 3, 5, 7, 9     $questions = range(1, 10, 3)     // gives 1, 4, 7, 10     $questions = range(10, 100, 10);     // gives 10, 20, 30, 40, 50, 60, 70, 80, 90, 100     $float = range(1, 10, 1.2);     // gives 1, 2.2, 3.4, 4.6, 5.8, 7, 8.2, 9.4 ?>