doukuang1950 2014-02-11 09:51
浏览 38

PHP array_diff返回所有结果

I am reading a text file and putting the contents which are file id's into an array.

I then have a new array with the same id's but one extra.

My aim is to compare these two arrays and print out the new file id or file id's

The problem I have is that When I use the function array_diff, it prints everything and not the actual difference between the two arrays.

$results = array_diff($pNewList, $pSavedList);
        $resultsCount = count($results);
        for($x = 0; $x < $resultsCount; $x++){
            echo $results[$x].'<br/>';
        } 

my output is printing every line even though the contents are the same in both arrays

  • 写回答

1条回答 默认 最新

  • dongpu8935 2014-02-11 10:08
    关注

    Try this

    $results = array_diff($pNewList, $pSavedList, TRUE);
    $resultsCount = count($results);
    for($x = 0; $x < $resultsCount; $x++){
        echo $results[$x].'<br/>';
    } 
    
    评论

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答