I have a problem to correctly define array_values ββwhen I do this:
$array[] = 'data1'; // I want [0 => 'data1'] unset($array[0]); // I want [] $array = array_values($array); // I want [] but keys resetted $array[] = 'data2'; // I want [0 => 'data2'] $array[] = 'data3'; // I want [0 => 'data2', 1 => 'data3'] dump($array);
I have a result:
array:2 [βΌ 1 => "data2" 2 => "data3" ]
But I want:
array:2 [βΌ 0 => "data2" 1 => "data3" ]
Can someone explain this to me? Because I lost a little: - /
For example, if I have an array with 10 values, delete the third value and make array_values on, it works well.
But if I remove the last value from the array, then when I do array_value, the next value I add always has id 1, not 0.
mpiot source share