Home >Backend Development >PHP Tutorial >PHP array deduplication example and analysis_PHP tutorial
Duplicates of one-dimensional array:
Just use the array_unique function. The usage example is as follows:
Duplicates of two-dimensional array:
We will discuss two-dimensional arrays in two situations. One is to delete duplicates because the value of a certain key name cannot be repeated; the other is to delete duplicates because the internal one-dimensional array cannot be exactly the same, as follows Example:
㈠Because the value of a certain key name cannot be repeated, delete duplicates
Copy code
The code is as follows:
R> Print_r ($ BB)
? & Gt;
Show results: array ([0] = & gt; array ([0] = & gt; 123 [1] = & gt; Zhang San San ) [1] => Array ( [0]=> 123 [1] => Li Si) [2]=> Array ( [0] => 124 [1]=> Wang Wu) [ 4] => Array ( [0]=> 126 [1] => Zhao Liu))
http://www.bkjia.com/PHPjc/621726.html
http: //www.bkjia.com/PHPjc/621726.html