Q:

Write a PHP program to remove duplicates from a sorted list

0

Write a PHP program to remove duplicates from a sorted list.

Input: (1,1,2,2,3,4,5,5)
Output: (1,2,3,4,5)

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
function remove_duplicates_list($list1) {
  $nums_unique = array_values(array_unique($list1));
  return $nums_unique ;
}
$nums = array(1,1,2,2,3,4,5,5);
print_r(remove_duplicates_list($nums));
?>

Sample Output:

Array                                                       
(                                                           
    [0] => 1                                                
    [1] => 2                                                
    [2] => 3                                                
    [3] => 4                                                
    [4] => 5 )                   

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now