Replace Array Keys with Ascending Numbers
arrays, element, key, php
Solution
This will renumber the keys while preserving the order of elements.
$new_array = array_values($old_array);
Problem
I have an array that looks like this: ``` [867324] [id] => 867324 [name] => Example1 [345786] [id] => 345786 [name] => Example2 [268531] [id] => 268531 [name] => Example3 ``` So as you can see, the first elements aren't in any specific order. For the purpose of the example, you can just consider them random numbers. The end result I would like to end up with is: ``` [0] [id] => 867324 [name] => Example1 [1] [id] => 345786 [name] => Example2 [2] [id] => 268531 [name] => Example3 ``` I've tried exploding, but clearly I must be doing something wrong. Any help is appreciated!