# unique()

{% code title="Example.php" %}

```php
<?php
use kim\present\utils\arrays\ArrayUtils;

$arrayUtils = ArrayUtils::from(["a", "a", "a", "b", "c", "c", "d"]);

$arrayUtils->unique();
// expected output: ["a", "b", "c", "d"]
```

{% endcode %}

## Syntax

```php
$arrayUtils->unique(int $sort_flags = SORT_STRING) : ArrayUtils;
```

### Parameter

* `$sortFlags` <img src="https://2976351099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKYhyHaArG9Gsnmdxc8%2F-MKk9I82AGQBHkmwnVvk%2F-MKk9YjCz_YkVR1YiRy-%2FBADGE_OPTIONAL.svg?alt=media&#x26;token=3fbbac84-2f1b-40af-a991-b2eff659866a" alt="" data-size="line">&#x20;

  > Used to modify the sorting behavior using these values:
  >
  > Sorting type flags:
  >
  > * **`SORT_REGULAR`** - compare items normally (don't change types)
  > * **`SORT_NUMERIC`** - compare items numerically
  > * **`SORT_STRING`** - compare items as strings
  > * **`SORT_LOCALE_STRING`** - compare items as strings, based on the current locale.

### Return value

* A filtered array.

## Prefixing

```php
$arrayUtils->uniqueAs(int $sort_flags = SORT_STRING) : array;
```

```php
ArrayUtils::uniqueFrom(iterable $from, int $sort_flags = SORT_STRING) : ArrayUtils;
```

```php
ArrayUtils::uniqueFromAs(iterable $from, int $sort_flags = SORT_STRING) : array;
```

## References

{% embed url="<https://www.php.net/manual/en/function.array-chunk>" %}
