gpt4 book ai didi

php - 将一个 php 数组分成两个

转载 作者:行者123 更新时间:2023-12-02 05:36:49 28 4
gpt4 key购买 nike

我有一个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);

关于php - 将一个 php 数组分成两个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27249883/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com