Home  >  Article  >  Backend Development  >  php数组有关问题 怎么判断两个数组不同的数据,并且输出

php数组有关问题 怎么判断两个数组不同的数据,并且输出

WBOY
WBOYOriginal
2016-06-13 10:32:59817browse

php数组问题 如何判断两个数组不同的数据,并且输出
如题 假设有两个数组
$a=array(1,2,3,4,5,6,7,8,9,0);

$b=array(1,3,5,7,9);
请教怎么讲两个数组不同的数据输出
我用for循环 只是输出了相同的
但是输出不同 就出问题 请教如何实现

------解决方案--------------------
两个数组不同的数据输出, 那就是非交集罗?

PHP code
$a=array(1,2,3,4,5,6,7,8,9,0);$b=array(1,3,5,7,9);$out1 = array_diff($a, $b);$out2 = array_diff($b, $a);$out3 = array_merge($out1, $out2);foreach($out3 as $rs3){    echo $rs3.' '; //2 4 6 8 0}<div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn