我有这个数组 $output 看起来像这样:
I have this array $output which looks like this:
Array(
[0] => Array(
[0] => 1a
[1] => 1b
[2] => 1c
)
[1] => Array(
[0] => 2a
[1] => 2b
[2] => 2c
)
[2] => Array(
[0] => 3a
[1] => 3b
[2] => 3c
)
[3] => Array(
[0] => 4a
[1] => 4b
[2] => 4c
)
)
等等...
当我想删除我只使用的第二个元素时:
When I want to remove the second element I just use:
$output = unset($output[1]);
获得以下内容:
Array(
[0] => Array(
[0] => 1a
[1] => 1b
[2] => 1c
)
[1] => Array(
[0] => 3a
[1] => 3b
[2] => 3c
)
[2] => Array(
[0] => 4a
[1] => 4b
[2] => 4c
)
)
我的问题是如何删除数组中每个元素的第二个元素 ([0][1], [1][1], [2][1], [3][1] ,...) 得到以下内容:
My question is how to remove every second element of every element in the array ([0][1], [1][1], [2][1], [3][1] ,...) to get the following:
Array(
[0] => Array(
[0] => 1a
[1] => 1c
)
[1] => Array(
[0] => 2a
[1] => 2c
)
[2] => Array(
[0] => 3a
[1] => 3c
)
[3] => Array(
[0] => 4a
[1] => 4c
)
)
不能用简单的命令完成,但可以使用循环:
Can't be done with a simple command, but you can use a loop:
foreach(array_keys($output) as $key) {
unset($output[$key][1]);
}
这篇关于取消设置多维数组中的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!