对于已调出的数据如何进行对比?并且去除重复的数据

WBOY
Release: 2016-06-23 13:11:30
Original
812 people have browsed it

for ($row = 2; $row     $val_1 = $sheet->getCellByColumnAndRow(0, $row)->getValue();
    $val_2 = $sheet->getCellByColumnAndRow(1, $row)->getValue();
    $val_3 = $sheet->getCellByColumnAndRow(2, $row)->getValue();
    $val_4 = $sheet->getCellByColumnAndRow(3, $row)->getValue();
    echo "

";
    echo "".$val_1."";
    echo "".$val_2."";
    echo "".$val_3."";
    echo "".$val_4."";
    echo "";
};
这是调出的表格数据

$sqls="select * from bm_excell_content";
     $commands=$connection->createCommand($sqls);
     $results=$commands->queryAll();
     foreach ($results as $key=>$val){
         $values=$val['username'];
         echo "$values";
     };
这是调出的数据库数据


这两个数据进行对比 该怎么实现?


回复讨论(解决方案)

循环比较,js代码实现

将$val_1存入数组$arr1,将$val['username']存入数组$arr2,然后计算差集$arr = array_diff($arr2,$arr1);
$arr 中就是只存在于数据库而不存在于表格中的人名了

将$val_1存入数组$arr1,将$val['username']存入数组$arr2,然后计算差集$arr = array_diff($arr2,$arr1);
$arr 中就是只存在于数据库而不存在于表格中的人名了


您好 像我这样调出的数据如何赋值给数组  谢谢您哈

循环比较,js代码实现


您这回答的也太笼统了吧,完全不会做啊

问题已解决 虽然没有按照各位朋友的意见来解决 但总算解决了

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!