我正在接受以下的回复
$myObj = Array
(
[0] => stdClass Object
(
[parameterName] => Age
[parameterValue] => 14
[income] => 700000
[famMember] => 9
)
[1] => stdClass Object
(
[parameterName] => location
[parameterValue] => Pune
[income] => 700000
[famMember] => 9
)
)
我想要的是将stdClass对象组合为单个
Array
(
[0] => stdClass Object
(
[parameterName] => Age
[parameterValue] => 14
[parameterName] => location
[parameterValue] => Pune
[income] => 700000
[famMember] => 9
)
)
请帮助我如何获得它。
答案 0 :(得分:0)
您可以使用array_merge_recursive()
但您的输出值应该是数组
例如:
$ar1 = array("color" => "red", "name"=> 5);
$ar2 = array("name"=>10, "color" => "green");
$result = array_merge_recursive($ar1, $ar2);
print_r($result);
输出是:
Array
(
[color] => Array
(
[0] => red
[1] => green
)
[name] => Array
(
[0] => 5
[1] => 10
)
)