2 つの JSON 配列をマージする方法
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->$json1 = <<<ETE [ {"a":"ab"}, {"a":"da"}, {"a":"gf"}, {"a":"ta"}, {"a":"lc"}, {"a":"ea"}, {"a":"ij"}, {"a":"vb"}, {"a":"lp"}, {"a":"uw"}, {"a":"il"} ] ETE; $json2 = <<<ETE [ {"a":"aa"}, {"a":"ca"}, {"a":"ga"}, {"a":"ha"}, {"a":"la"}, {"a":"oa"}, {"a":"aj"}, {"a":"vr"}, {"a":"pl"}, {"a":"di"}, {"a":"im"} ] ETE;
$arr1 = 配列(); $arr2 = 配列(); $arr3 = 配列(); $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); 関数 json_to_array($web){ $arr=配列(); foreach($web as $k=>$w){ if(is_object($w)) $arr[$k]=json_to_array($w); それ以外の場合は $arr[$k]=$w; } $arr を返します。 <div class="clear"></div>