array_unique 함수

함수 array_unique는 배열에서 반복되는 요소(중복)의 제거를 수행합니다.

구문

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

예시

배열에서 중복을 제거해 봅시다:

php<?php
  $arr = [1, 1, 1, 2, 2, 3];
  var_dump(array_unique($arr));
?>

코드 실행 결과:

php[1, 2, 3]

함께 보기