标签:php 对比数组
<?php function diffArray($arr1 , $arr2 ){ $arrRet = array(); foreach ($arr1 as $key => $value){ if($arr1[$key] != $arr2[$key]){ if(array_key_exists($key, $arrRet)){ array_push($arrRet, $key); }else{ $arrRet[]=$key; } } } return $arrRet; } $arr1 = array( "channelNameShort"=> "百度时代公司", "channelName"=>"百度时代责任有限公司", "rawUrl"=>"http://www.baidu.com", "logoUrl"=> "http://t11.baidu.com/it/u=3114404026,3614407463&fm=58", "channelType"=> array( "210010004", "210010007", ), ); $arr2 = array( "channelNameShort"=> "百度时代公司", "channelName"=>"百度在线公司", "rawUrl"=>"http://www.baidu.com", "logoUrl"=> "http://t11.baidu.com/it/u=3114404026,3614407463&fm=58", "channelType"=> array( "210010004", "210010017", ), ); var_dump(diffArray($arr1, $arr2));
结果:
array 0 => string ‘channelName‘ (length=11) 1 => string ‘channelType‘ (length=11)
本文出自 “梦朝思夕” 博客,请务必保留此出处http://qiangmzsx.blog.51cto.com/2052549/1553325
标签:php 对比数组
原文地址:http://qiangmzsx.blog.51cto.com/2052549/1553325