我有一个大的多维数组,如下所示:
$valueall = array();
$valueall[employee_id][salary_month][for_the_month][ed_type][ed_code]=>floatval(amount);
如何仅过滤掉ed_type = T数组并存储到新数组中?
数组的输出:
Array
(
[010789] => Array
(
[2018-04-01] => Array
(
[2018-04-01] => Array
(
[T] => Array
(
[101] => 4
[108] => 2
[109] => 1
)
[O] => Array
(
[155] => 35.5
)
[D] => Array
(
[445] => 1111
[446] => 0
)
)
[2018-03-01] => Array
(
[T] => Array
(
[102] => 2
)
[E] => Array
(
[201] => 651
[205] => 325
[214] => 20
[217] => 107
[235] => 40
[267] => 49
)
)
)
)
)
答案 0 :(得分:0)
您可以使用array_column。
$T = array_column($valueall, "T");
我无法测试它,但它应该给你101,108,109和102个值。
答案 1 :(得分:0)
实际上,您在使用import de.xxx.backend 1.0
时需要指定内键。见下文,我已经为您创建了一个快速摘要。
array_column
输出:
$records = [
"010789" => [
"2018-04-01" => [
"2018-04-01" => [
"T" => [
101 => 4,
108 => 2,
109 => 1,
],
0 => [
155 => 35.5
],
"D" => [
445 => 1111,
446 => 0
]
],
"2018-03-01" => [
"T" => [
102 => 2
],
"E" => [
201 => 651,
205 => 325,
214 => 20,
217 => 107,
235 => 40,
267 => 49
]
]
]
]
];
print_r(array_column($records["010789"]["2018-04-01"], "T"));
让我知道是否有帮助。谢谢。