array_unique($arrary) function;
1. <?php function removeDuplicates($nums){ $nums=array_unique($nums); return $nums; } print_r (removeDuplicates([3, 5, 1,2,3, 5])); ?> 2. <?php function removeDuplicates($nums){ $result=[]; foreach ($nums as $num){ if (!in_array($num, $result)){ $result[]=$num; } } return $result; } print_r (removeDuplicates([3, 5, 1,2,3, 5])); ?>
by Anna Tukvadze
2 years ago
PHP
26. Remove Duplicates from Sorted Array
Object Oriented PHP Tutorial
0
Pro tip: use ```triple backticks around text``` to write in code fences