How to remove duplicate values from array using PHP?
To remove duplicate values from an array using PHP, we have to use the PHP
array_unique()
function. It removes duplicate values or elements from the array. If our array contains string keys, then this function will keep the first encountered key for every value and will ignore all other subsequent keys.
BY Best Interview Question ON 31 Jul 2019
Example
$var = array("a"=>"best","b"=>"interview","c"=>"question","d"=>"interview");
print_r(array_unique($var));
OUTPUT
Array ( [a] => best [b] => interview [c] => question)