All pastes #125597 Raw Edit

Something

public text v1 · immutable
·published 2006-08-10 19:45 UTC
rendered paste body
Let's assume I make the following multidimensional array. The number of elements is dependent on an unknown variable (say, an sql num_rows) called $num_rows. 

for ($i=0;$i<$num_rows;$i++)
{
$row=mysql_fetch_array($result);
$array[$i]['stat1'] = ($row['stat1']);
$array[$i]['stat2'] = ($row['stat2']);
$array[$i]['stat3'] = ($row['stat3']);
$array[$i]['stat4'] = ($row['stat4']);
}

Let's assume $num_rows gave us 5 elements $array[0] to $array[4].

now lets
unset ($array['2']);

this leaves the array with $array[0]. $array[1], $array[3] and $array[4], and a gap in the indicies. 

we can rebuild the array with $array_values to fill up the hole in the array

$array=array_values($array);

The question is, will this reassign the ['stat1'] etc parts of the array as well, or will these be lost or what? 
For example
will $array[3]['stat1'] BEFORE using array_values be the same as $array[2]['stat1'] AFTER using array_values?