0

Possible Duplicate:
PHP reindex array?

Is there a specific PHP function to assign new ordered keys to an array?

I have an array as follows:

array(
 0 =>'abc',
 2 =>'pqr',
 3 =>'xyz'
)

I want a new array out of this as follows:

array(
     0 =>'abc',
     1 =>'pqr',
     2 =>'xyz'
    )

Is there a PHP built-in function for this? I know I can do this with foreach.

Community
  • 1
  • 1
techie_28
  • 2,123
  • 4
  • 41
  • 62

1 Answers1

4

This will do the trick:

$aNew = array_values($aOld);
Wesley van Opdorp
  • 14,888
  • 4
  • 41
  • 59