Maison > Article > développement back-end > 怎么合并2个JSON数组
如何合并2个JSON数组
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$json1 =
$arr1 = array();$arr2 = array();$arr3 = array();$web=json_decode($json1);$arr1=json_to_array($web);$web=json_decode($json2);$arr2=json_to_array($web);$arr3 = array_merge($arr1,$arr2);echo "<pre class="brush:php;toolbar:false">";print_r($arr3);function json_to_array($web){$arr=array();foreach($web as $k=>$w){if(is_object($w)) $arr[$k]=json_to_array($w); else $arr[$k]=$w;}return $arr;}<div class="clear"> </div>