PHP array_unique() ফাংশন
প্রকল্প
একক মান অদূষিত করুন
<?php $a=array("a"=>"red","b"=>"green","c"=>"red"); print_r(array_unique($a)); ?>
Definition and Usage
The array_unique() function removes duplicate values from the array and returns the resulting array.
When the values of several array elements are equal, only the first element is retained, and the other elements are deleted.
The key names in the returned array remain unchanged.
Note:The retained array will keep the key name type of the first array item.
Syntax
array_unique(array)
Parameters | Description |
---|---|
array | Required. Specify the array. |
sortingtype |
Optional. Specify how to compare array elements/items. Possible values:
|
Description
array_unique() first sorts the values as strings, then keeps the first encountered key name for each value, and ignores all subsequent key names. This does not mean that the first occurrence of the same value in the unsorted array will be retained.
Technical Details
Return Value: | Returns the filtered array. |
PHP Version: | 4.0.1+ |
Update Log: |
In PHP 5.2.10,sortingtype Default value changed back to SORT_STRING. In PHP 5.2.9,sortingtype Default value changed to SORT_REGULAR. In previous versions, the default value of sortingtype was SORT_STRING. |