I have an array $a as below, then unset some elements from it's end. When adding new elements, while indexing, I assume php should ignore deleted ones and start from the last not unsetted one right? But it doesn't. How can i fix this?
$a = array(0,1,2);
unset($a[2]);
$a[] = 2;
//print_r prints => Array ( [0] => 0 [1] => 1 [3] => 2 )
//should be => Array ( [0] => 0 [1] => 1 [2] => 2 )