I will always unset an array value in my Site request.
unset($segments[0]);
How can I push back the arrays, so I get the “1” key to be the “0”?
Example:
$arr[0] = 'Balls';
$arr[1] = 'Test';
unset($arr[0]);
(magicalfunctionthatpushback)
echo $arr[0]; //Test
There must be a function for this or do I need to use a for loop?
Use
array_shiftto remove the element instead of unset.There’s also the array_values function to get a new array reindexed from zero. I would choose
array_shift()in your scenario though.