I'm looking for the way to replace my array. My first array below:
$arr1 = Array
(
[0] => stdClass Object
(
[values] => Array
(
[0] => stdClass Object
(
[field_value] => Green
[count] => 0
)
[1] => stdClass Object
(
[field_value] => Red
[count] => 0
)
)
)
[1] => stdClass Object
(
[values] => Array
(
[0] => stdClass Object
(
[field_value] => Plastic
[count] => 0
)
[1] => stdClass Object
(
[field_value] => Metall
[count] => 0
)
)
)
My second array:
$arr2 = Array
(
[0] => 2
[1] => 6
[2] => 3
[3] => 4
)
And I would like to get this:
Array
(
[0] => stdClass Object
(
[values] => Array
(
[0] => stdClass Object
(
[field_value] => Green
[count] => 2
)
[1] => stdClass Object
(
[field_value] => Red
[count] => 6
)
)
)
[1] => stdClass Object
(
[values] => Array
(
[0] => stdClass Object
(
[field_value] => Plastic
[count] => 3
)
[1] => stdClass Object
(
[field_value] => Metall
[count] => 4
)
)
)
I have tried to use array_map function but without any success.
array_map(function($a,$b){$a = $b; return $a;}, $arr1, $arr2);
Thanks!
Create your own function as needed, and customize as you like, see below example:
and you may call it like: