If you want to declare an array this way, which you should do:
$array = array(100 => 'a', 200 => 'b', 300 => 'c', 400 => 'd', 500 => 'e');
Note that if you add a new element in shorter $array ( $array[] = 'f' ), the assigned key will be 501 .
If you want to convert regular array indices to hundreds-on-one, you can do this:
$temp = array(); foreach ($array as $key => $value) { $temp[(($key + 1) * 100)] = $value; } $array = $temp;
But perhaps you do not need to convert the array and refer to your current one instead:
$i = $hundredBasedIndex / 100 - 1; echo $array[$i]; // or directly echo $array[($hundredBasedIndex / 100 - 1)];
source share