Write a PHP program to remove duplicates from a sorted list
array_unique():-
The array_unique() function removes duplicate values from an array. If two or more array values are the same, the first appearance will be kept and the other will be removed.
array_values:-
The array_values() function returns an array containing all the values of an array.
code:
<?php
$new = array(2,1,2,3,4,5,4);
$newarr = array_values(array_unique($list1));
print_r($newarr);
?>
Post a Comment
If you have any doubts, Please let me know
Thanks!