0

I have an array that currently looks similar to this:

Array 
(
    [0] => Array 
        (
        [name] => Mike
        [date] => 2014
        )
    [1] => Array 
        (
        [name] => Jason
        [date] => 2011
        )
    [4] => Array 
        (
        [name] => Dan
        [date] => 2009
        )
    [8] => Array 
        (
        [name] => Jeff
        [date] => 2012
        )
)

Using php, How do I rename the numbers so they read consecutively, like so?… [0][1][2][3] instead of [0][1][4][8]

user2714240
  • 7
  • 1
  • 5
  • How is the array generated? Is it not possible to set them there? If not, try looking at this page: http://www.php.net/manual/en/array.sorting.php (I simply searched Google for "PHP array sort" - Who'd have thought..) – James Feb 21 '14 at 23:21

1 Answers1

0

You could just do $array = array_values($array); as suggested in this answer.

Community
  • 1
  • 1
George Brighton
  • 5,131
  • 9
  • 27
  • 36
  • Thank you George. I am new to php and without a proper education it is difficult for me to teach myself the basics to allow me to navigate this abstract space. I really appreciate the efforts of people like you on Stack Overflow. – user2714240 Feb 21 '14 at 23:36