BudiBadu Logo
Toolbadu

array_unique Online

Test PHP's array_unique() function online using real PHP 8.2. Remove duplicate values from arrays and see the results instantly. Perfect for testing data deduplication.

array_unique(array $array, int $flags = SORT_STRING): array

PHP Array Input

Enter a PHP array with duplicate values

Sort Flags

PHP Code

This is the actual PHP code that will be executed

Loading editor...

Common Examples

array_unique() Function Guide

About array_unique()

This tool runs actual PHP 8.2 code on our server using Docker containers. The array_unique() function removes duplicate values from an array and returns a new array with only unique values. The keys are preserved from the original array.

  • Removes duplicate values
  • Preserves original keys
  • Returns array with unique values
  • Supports different comparison flags
  • First occurrence is kept

Sort Flags

  • SORT_STRING - Compare as strings (default)
  • SORT_NUMERIC - Compare numerically
  • SORT_REGULAR - Compare normally (mixed types)

💡 Note: Keys are preserved! Use array_values() after array_unique() to re-index the array from 0.

Request a Feature

Have an idea to improve this tool? Share your suggestions and help us make it better! (One request per day)

0/1000 characters