Return to Snippet

Revision: 62462
at February 25, 2013 18:45 by apphp-snippets


Initial Code
<?php
$input = array("a"=>"apple", "pear", "b"=>"apple", "orange", "avocado", "banana");
print_r($input);
$result = array_unique($input);
print_r($result);
?>

Initial URL
http://www.apphp.com/index.php?snippet=php-remove-duplicates-in-array

Initial Description
This code allows to remove all duplicate elements from an array using PHP array_unique() function.

Initial Title
Remove duplicate elements from array in PHP

Initial Tags
php

Initial Language
PHP