In php we have in built array function that can be used to remove duplicate values from the array.
Example with code and syntax:
<?php
$myarr=array("x"=>"Amol","y"=>"Sagar","z"=>"Amol");
print_r(array_unique($myarr));
?>
$myarr=array("x"=>"Amol","y"=>"Sagar","z"=>"Amol");
print_r(array_unique($myarr));
?>
Above code will remove the third element z=Amol from array and return the array with unique values.
This is how we can remove duplicate values from an array in PHP.
No comments:
Post a Comment