php method to delete duplicate data in an array: You can use the array_unique() function to delete. The array_unique() function is used to remove duplicate values from the array and return the filtered array. If there are multiple array values with the same value, only the first value is retained.
#You can use the built-in function array_unique() function to remove duplicate elements. The array_unique() function removes duplicate values from an array and returns the filtered array. If two or more array values are the same, only the first value is retained and the other values are removed.
(Recommended tutorial: php graphic tutorial)
Syntax:
array_unique(array)
Parameters:
array Required. Specifies an array.
sortingtype Optional. Specifies the sorting type.
(Video tutorial recommendation: php video tutorial)
Example:
<?php $a=array("a"=>"red","b"=>"green","c"=>"red"); print_r(array_unique($a)); ?>
Output result:
Array ( [a] => red [b] => green )
The above is the detailed content of How to delete duplicate data in an array in php. For more information, please follow other related articles on the PHP Chinese website!