我有如下的数组,
Array
(
[14289] => Array
(
[0] => Karthikeyan
[1] => Mathi
[2] => RAvi
)
[14279] => Array
(
[0] => Karthikeyan
[1] => Mathi
[2] => RAvi
)
[14288] => Array
(
[0] => Karthikeyan
)
[14291] => Array
(
[0] => Mathi
)
[14284] => Array
(
[0] => RAvi
)
)
如果我从[14289]这个取消设置索引[1]值。之后数组显示如下,
Array
(
[14289] => Array
(
[0] => Karthikeyan
[2] => RAvi
)
[14279] => Array
(
[0] => Karthikeyan
[1] => Mathi
[2] => RAvi
)
[14288] => Array
(
[0] => Karthikeyan
)
[14291] => Array
(
[0] => Mathi
)
[14284] => Array
(
[0] => RAvi
)
)
但我需要[14289]值,如下所示,
Array
(
[14289] => Array
(
[0] => Karthikeyan
[1] => RAvi
)
........
键值应为[1]而不是[2]。我怎么能这样做?
答案 0 :(得分:0)
在阵列上使用array_values
。
答案 1 :(得分:0)
后
unset $example_array[14289][1];
DO
$example_array[14289]= array_values($example_array[14289]);