You also can use functions to implement re-index if you dont really need the actual re-indexing .
function get_array_index(&$array, $index, $index_start=0)
{
return $array[$index_start - $index] ;
}
You probably should make new functions to use your array.
I wrote 2 functions so i can re-index the array for fake .
function array_get(&$array, $index, $index_start=0)
{
return $array[$index - $index_start] ;
}
function array_set(&$array, $index, $val, $index_start=0)
{
$array[$index - $index_start] = $val;
}
$index_start = 0 ; // what is the first offset
// input
$input = [1,2,3,4,5] ;
// get index 0
echo $input[0] ; // 1 ; this line refer is actuall array
echo '<br/>';
echo array_get($input, 0, $index_start) ; // 1 ; this is what we goona use for re-indexing purpose
echo '<br/>';
// get index 2
echo $input[2] ; // 3
echo '<br/>';
echo array_get($input, 2, $index_start) ; // 3
echo '<br/>';
// reset $input[2]
array_set($input, 2, 12, $index_start) ; // change 3 -> 12
echo array_get($input, 2, $index_start) ; // 12
echo '<br/>';
// let's re-index array
$index_start = 5 ; // first index is 5 now
// it's seems to a re-index happend but the actuall array did'nt changed
echo array_get($input, 5, $index_start) ; // must be 1
echo '<br/>';
echo array_get($input, 6, $index_start) ; // must be 2
echo '<br/>';
echo array_get($input, 7, $index_start) ; // must be 12
echo '<br/>';
echo array_get($input, 8, $index_start) ; // must be 4
echo '<br/>';
echo array_get($input, 9, $index_start) ; // must be 5
echo '<br/>';
// reset $input[9]
array_set($input, 9, 15, $index_start) ; // change 5 -> 15
echo array_get($input, 9, $index_start) ; // 15
echo '<br/>';
If you need to re-index the array in real this functions wont help you .