dongtai419309 2011-10-19 08:05
浏览 3
已采纳

分配新数组键[重复]

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.

  • 写回答

1条回答 默认 最新

  • duanjiao1256 2011-10-19 08:07
    关注

    This will do the trick:

    $aNew = array_values($aOld);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?