Home >Backend Development >PHP Tutorial >php array_unique example of removing duplicate values ​​from a one-dimensional array

php array_unique example of removing duplicate values ​​from a one-dimensional array

WBOY
WBOYOriginal
2016-07-25 09:04:351256browse
  1. /**
  2. * Remove duplicate elements from the array
  3. * link: bbs.it-home.org
  4. * date: 2013/2/25
  5. */
  6. $input = array ("1" => "Apple", "Orange", "Yali", "a" => " Orange", "Banana", "Apple") ;
  7. $result = array_unique ( $input ) ;
  8. print_r ( $result ) ;
  9. ?>
Copy the code

Output result: array ( [1] => apple [2] => orange [3] => pear [4] => banana )



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn