Suppose that the array is called $my _array;
Copy CodeThe code is as follows:
Creates a new, empty array.
$tmp _array = Array ();
$new _array = Array ();
1. Loops out all the rows. ($val is a row)
foreach ($my _array as $k = + $val) {
$hash = MD5 (Json_encode ($val));
if (In_array ($hash, $tmp _array)) {
Echo (' This line has been over ');
}else{
2. In the body of the Foreach loop, the hash of each array object is assigned to that temporary array.
$tmp _array[] = $hash;
$new _array[] = $val;
}
}
Print_r ($new _array);
$new _array is a filtered array of data that is not duplicated.
http://www.bkjia.com/PHPjc/825203.html www.bkjia.com true http://www.bkjia.com/PHPjc/825203.html techarticle Suppose the array $my _array; Copy the code as follows://Create a new empty array. $tmp _array = Array (), $new _array = Array ();//1. Loop out all rows. ($val is a row) ...