May 2017
Intermediate to advanced
340 pages
8h 16m
English
A numeric array does not mean it only holds numeric data. In fact, it means the indexes will be numbers only. In PHP they can either be sequential or non-sequential but they have to be numeric. In numeric arrays, values are stored and accessed in a linear way. Here are some examples of PHP numeric array:
$array = [10,20,30,40,50]; $array[] = 70; $array[] = 80; $arraySize = count($array); for($i = 0;$i<$arraySize;$i++) { echo "Position ".$i." holds the value ".$array[$i]."\n"; }
This will have the following output:
Position 0 holds the value 10 Position 1 holds the value 20 Position 2 holds the value 30 Position 3 holds the value 40 Position 4 holds the value 50 Position 5 holds the value 70 Position 6 holds the value 80
Read now
Unlock full access