【发布时间】:2012-10-25 03:48:18
【问题描述】:
我有对象数组,我想要做的是将 123, 150, 50 之类的索引重置为 0,1,2 。我已经完成了 array_values();但它会删除第一个数组“123”。
如何使索引号从 0 开始。使 123, 150, 50, 变成 0,1,2
array(
123 =>
User::__set_state(array(
_type' => 'student',
'id' =>'23'}),
150=>
User::__set_state(array(
'_type' => 'student',
'id' =>'29'}),
50=>
User::__set_state(array(
'_type' => 'student',
'id' =>'12'})
输出
array(
150=>
User::__set_state(array(
'_type' => 'student',
'id' =>'29'}),
50=>
User::__set_state(array(
'_type' => 'student',
'id' =>'12'})
【问题讨论】:
-
array_values 删除索引?奇怪...你能给我们确切的输入和输出吗?
-
谢谢,但是你能用 var_dump 代替写输入和输出吗?
标签: php arrays arraylist jquery-ui-sortable