如:
$one = {"a": 1, "b": 2};
$two = {"c": 3, "d": 4};
怎么拼接成下面这种:
$three = {"a": 1, "b": 2, "c": 3, "d": 4};
我用array_merge函数返回的是下面这种结果:
$three = [{"a": 1, "b": 2},{"c": 3, "d": 4}];
还有其他函数可用吗?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
不就array_merge么
使用
json_decode($one,true)json转数组再拼接,拼完json_encode($one)转回来再试试吧,使用array_merry没问题的。
json_decode成数组,再array_merge