gpt4 book ai didi

php - 如何在php中将一个元素添加到子数组中

转载 作者:行者123 更新时间:2023-12-05 08:39:22 24 4
gpt4 key购买 nike

<分区>

我有一个数组:

$main_arr = [
0=>[
"el 01",
"el 02",
"el 03",
],
1=>[
"el 11",
"el 12",
"el 13",
],
2=>[
"el 21",
"el 22",
"el 23",
],
];

在 php 中是否有像 ninja_array_method($main_arr, "el new") 这样的函数或单个语句将新元素添加到所有子数组中:

$main_arr = [
0=>[
"el 01",
"el 02",
"el 03",
"el new",
],
1=>[
"el 11",
"el 12",
"el 13",
"el new",
],
2=>[
"el 21",
"el 22",
"el 23",
"el new",
],
];

我只想将这些元素“el new”添加到所有数组中,而不用在一行中进行任何更改,或者只是像 add_el($main_arr, "el new") 这样的方法

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