Php - How to create a simple array, Php range function create array
How to create a simple array
The easiest way to create an alphabets is using range() function
// to get a array of characters from a to f $a = range('a','f'); print_r($a); // to get a array of characters from d to h $b = range('d','h'); print_r($b); ?>
Result:
Array ( [0] => a [1] => b [2] => c [3] => d [4] => e [5] => f ) Array ( [0] => d [1] => e [2] => f [3] => g [4] => h )
Range can also be used to get an array of numbers with a increment range between each number.
Say, if I want numbers 10,20,30,40,50,60 in an array I can use range as
<?php $a = range(0,60,10); print_r($a); ?>
Result:
Array ( [0] => 10 [1] => 20 [2] => 30 [3] => 40 [4] => 50 [5] => 60 )
The topic on Php - How to create a simple array is posted by - Anjana
Hope you have enjoyed, Php - How to create a simple arrayThanks for your time