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)
<?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 )
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
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