我有一个如下所示的数组:
Array
(
[answer123] => Array
(
[name] => something
[url] => something
)
[answer5829] => Array
(
[name] => something
[url] => something
)
[answer9271] => Array
(
[name] => something
[url] => something
)
)
是否可以将键[answer123],[answer5829],[answer9271]更改为[0],[1],[2]等等?如果是这样,怎么样?
答案 0 :(得分:5)
您可以通过调用“array_values”来“重置”数组的索引。 请参阅PHP Manual以供参考。它以“已清理”的顺序返回传递的数组。
$cleanedArray = array_values($dirtyArray);