有没有办法删除数组中的维度(只有它是空的),用文字解释是非常困难的,这就是我想要做的事情:< / p>
我有一个返回的数组:
(
[region1] => Array
(
[] => Array
(
[0] => citie1
[1] => citie2
)
[region2] => Array
(
[] => Array
(
[0] => citie1
[1] => citie2
[2] => citie3
)
)
)
我希望它是:
(
[region1] => Array
(
[0] => citie1
[1] => citie2
)
[region2] => Array
(
[0] => citie1
[1] => citie2
[2] => citie3
)
)
答案 0 :(得分:1)
foreach($array as $key => $value) {
$array[$key] = reset($value);
}
这将用该值的第一个元素替换外部数组中的每个值。