0

I have an array that looks like this:

Array
(
    [answer123] => Array
        (
            [name] => something
            [url] => something
        )

    [answer5829] => Array
        (
            [name] => something
            [url] => something
        )

    [answer9271] => Array
        (
            [name] => something
            [url] => something
        )
)

Would it be possible to change the keys [answer123], [answer5829], [answer9271] to [0], [1], [2] and so on? If so, how?

Reality-Torrent
  • 356
  • 3
  • 14

1 Answers1

5

You can "reset" the array's indices by calling "array_values". See PHP Manual for reference. It returns the passed array in the "cleaned" order.

$cleanedArray = array_values($dirtyArray);
Dr. Dreave
  • 539
  • 5
  • 13