Php – How to reindex array with negative integer key value, so that items 0,1,2,3,-1 sort to -1,0,1,2,3, and then renumbered to 0,1,2,3,4?
Suppose I have this: $arr = []; $arr[0] = 'second'; $arr[-1] = 'first'; How do I change that to $arr[0 => 'first', 1 => 'second'] This is the best I've come up with: $new = []; foreach ($arr as $key…