<?php header("Content-type:text/html;charset=utf-8"); $old = array(1,2,3,4,5); $new = array(3,4,5,8); echo "原始数组内容array(1,2,3,4,5)<hr/>"; echo "新数组内容是array(3,4,5,8)<hr/>"; echo "旧的比新的:".print_r(array_diff($old, $new));//被删掉的数据 echo "<hr/>"; echo "新的比旧的:".print_r(array_diff($new,$old)); echo "<hr/>"; $a = array_diff($old,array_diff($old, $new));//应该剩下的 print_r(array_merge($a,array_diff($new,$old))); echo "<hr/>"; print_r(array_merge(array_diff($old,array_diff($old, $new)),array_diff($new,$old)));
时间: 2024-11-05 18:39:11