我有两个数组:
Array
(
[0] => stdClass Object
(
[id] => 1
[values] => Array
(
[0] => stdClass Object
(
[id] => 2
[field_value] => Green
[ordering] => 0
[count] => 0
)
[1] => stdClass Object
(
[id] => 1
[field_value] => Red
[ordering] => 1
[count] => 0
)
...
)
)
[1] => stdClass Object
(
[id] => 2
[values] => Array
(
[0] => stdClass Object
(
[id] => 2
[field_value] => Metall
[ordering] => 0
[count] => 0
)
[1] => stdClass Object
(
[id] => 1
[field_value] => Plastic
[ordering] => 1
[count] => 0
)
...
)
)
)
第二阵列:
Array
(
[0] => 2
[1] => 6
[2] => 5
[3] => 3
)
我想得到输出数组:
Array
(
[0] => stdClass Object
(
[id] => 1
[values] => Array
(
[0] => stdClass Object
(
[id] => 2
[field_value] => Green
[ordering] => 0
[count] => 2
)
[1] => stdClass Object
(
[id] => 1
[field_value] => Red
[ordering] => 1
[count] => 6
)
...
)
)
[1] => stdClass Object
(
[id] => 2
[values] => Array
(
[0] => stdClass Object
(
[id] => 2
[field_value] => Metall
[ordering] => 0
[count] => 5
)
[1] => stdClass Object
(
[id] => 1
[field_value] => Plastic
[ordering] => 1
[count] => 3
)
...
)
)
)
如何使用array_map()
或array_walk_recursive()
函数执行此操作?