I have an array with not-so-continuous index numbers like below:
$arr[0] = array( 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' );
$arr[1] = array( 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' );
$arr[3] = array( 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' );
$arr[7] = array( 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' );
$arr[8] = array( 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' );
And I want the index numbers to be continuous like 0, 1, 2, 3, 4, but the below code doesn't work. It only works up to the continuous index numbers, which in this case are 0 and 1, and just stops there.
$idx = 0;
$new_arr = array();
for( $i = 0; $i < sizeof( $arr ); $i++ ) {
if( isset( $arr[$i] ) ) {
$new_arr[$idx] = $arr[$i];
$idx++;
}
}
Any idea how to get this work?