Demo For: How To Remove Duplicates From Array Using PHP
Example 1: Removing a duplicate value from the array - Remove value "apple"Following are the original array contents:
Array ( [0] => apple [1] => mango [2] => grapes [3] => pineapple [4] => apple [5] => guava [6] => apple )Following are the array contents AFTER removing the duplicate values from array:
Array ( [0] => apple [1] => mango [2] => grapes [3] => pineapple [5] => guava )
Example 2: Removing a duplicate value from the array - Remove value "grapes"
Following are the original array contents:
Array ( [0] => apple [1] => mango [2] => grapes [3] => pineapple [4] => apple [5] => guava [6] => apple )Following are the array contents AFTER removing the value from array:
Array ( [0] => apple [1] => mango [2] => grapes [3] => pineapple [5] => guava )