Say you used to have a nice little array which you’ve since gone and hacked to pieces through various merges, and cuttings, etc., resulting is a rather non-uniform, keyed array mess.

Now in order to return to some sort of sanity it might be a good idea to take that input array of yours and retrieve from it a new array containing all the values (currently finding themselves inhabiting the original mess) but with a bright and shiny new, numerically ordered index.

Easy.

Simply make use of the handy PHP array_values function which basically takes an input array, retrieves all values from it and then creates a new array with all those values tucked behind a nice sequential numeric index.

So for example, an array looking like this {a->tomato,b->apple} would now become {0->tomato,1->apple}.

It really is that simple.

Related Link: http://www.php.net/manual/en/function.array-values.php