array_unique
array_unique — Removes duplicate values from an array.Description
array_unique( array $array,Takes an input array and returns a new array without duplicate values. Note that keys are preserved. If multiple elements compare equal under the given flags, then the key and value of the first equal element will be retained.
int $flags = SORT_STRING ): array
Note:Two elements are considered equal if and only if (string) $elem1 === (string) $elem2 i.e. when the string representation is the same, the first element will be used.
Parameters
array
The input array.
int
The optional sorting flags. It can be any combination of SORT_REGULAR, SORT_NUMERIC, SORT_STRING, SORT_LOCALE_STRING, SORT_NATURAL, SORT_FLAG_CASE or SORT_NATURAL_CASE.
Return Values
Returns the filtered array.More information about array_unique on official PHP documentation site
array_unique - Popular snippets
- PHP 8.1 / MySQL 5.7 file_get_contents simplexml_load_string json_encode json_decode print_r array_unique
last run:
2023-11-01 17:43:41
12
- PHP 8.1 / MySQL 5.7 file_get_contents simplexml_load_string json_encode json_decode print_r array_unique
last run:
2023-11-08 17:10:39
8
- PHP 8.1 / MySQL 5.7 file_get_contents simplexml_load_string json_encode json_decode array_unique print_r
last run:
2023-10-27 16:46:56
8
- PHP 8.1 / MySQL 5.7 file_get_contents simplexml_load_string json_encode json_decode array_unique print_r
last run:
2023-11-01 17:56:02
7
- PHP 8.1 / MySQL 5.7 file_get_contents simplexml_load_string json_encode json_decode array_unique print_r
last run:
2023-10-25 17:06:46
7
- PHP 8.1 / MySQL 8.0 array_push array_unique var_export
last run:
2024-06-30 22:29:16
7
- PHP 8.1 / MySQL 5.7 file_get_contents simplexml_load_string json_encode json_decode print_r array_unique
last run:
2023-11-01 17:15:00
6
- PHP 8.1 / MySQL 5.7 file_get_contents simplexml_load_string json_encode json_decode array_unique print_r
last run:
2023-11-01 18:05:32
6
- PHP 8.1 / MySQL 5.7 file_get_contents simplexml_load_string json_encode json_decode array_unique print_r
last run:
2023-11-01 17:12:39
6
- PHP 8.0 / MySQL 8.0 array_unique explode implode
last run:
2024-07-28 23:40:26
6
array_unique - New snippets
-
PHP 8.1 / MySQL 5.7 array_merge array_unique var_dump
added at:
2024-12-17 08:20:33
1
-
PHP 8.1 / MySQL 5.7 array_merge array_unique array_values var_dump
added at:
2024-12-17 08:20:24
2
-
PHP 8.1 / MySQL 5.7 array_merge array_unique array_values var_dump
added at:
2024-12-17 08:20:12
1
-
PHP 8.1 / MySQL 5.7 array_merge array_unique array_values var_dump
added at:
2024-12-17 08:19:27
2
-
PHP 8.1 / MySQL 5.7 array_merge array_values array_unique var_dump
added at:
2024-12-17 08:19:18
1
-
PHP 8.1 / MySQL 5.7 array_merge array_values array_unique var_dump
added at:
2024-12-17 08:18:59
1
-
PHP 8.1 / MySQL 5.7 array_merge array_values array_unique var_dump
added at:
2024-12-17 08:18:16
1
-
PHP 8.1 / MySQL 5.7 var_dump array_unique
added at:
2024-09-25 15:46:15
1
-
PHP 8.2.13 / MySQL 8.0 array_push array_unique var_export
added at:
2024-06-30 23:10:29
1
-
PHP 8.2.13 / MySQL 8.0 array_push array_unique var_export
added at:
2024-06-30 22:52:06
1