我有一个 PHP 数组
Array
(
[0] => Array(
[0] => 24
[1] => 1
[2] => 0
[3] => 4
)
[1] => Array(
[0] => 2
[1] => 23
[2] => 5
[3] => 0
)
[2] => Array(
[0] => 22
[1] => 3
[2] => 0
[3] => 6
)
)
对于列 [2][3],我想从上面的数组创建一个新数组,应如下所示。
Array
(
[0] => Array(
[0] => 0
[1] => 4
)
[1] => Array(
[0] => 5
[1] => 0
)
[2] => Array(
[0] => 0
[1] => 6
)
)
array_map(function($elem) {
return array($elem[2], $elem[3]);
}, $array);
试试这个 -
$newArray = array();
foreach ($yourArray as $value) {
$newArray[] = array($value[2], $value[3]);
}