Skip to content

Instantly share code, notes, and snippets.

@4RSIM3R
Created October 12, 2023 03:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 4RSIM3R/98af437e847e5fe575d4d99d64335adb to your computer and use it in GitHub Desktop.
Save 4RSIM3R/98af437e847e5fe575d4d99d64335adb to your computer and use it in GitHub Desktop.
<?php
// hilangkan semua item yang duplikat dalam sebuah array
// contoh input : [1, 1, 2, 3, 4, 4, 5]
// maka output nya : [1, 2, 3, 4, 5]
function removeAllDuplicates($arr)
{
return $arr;
}
$arr = [1, 1, 2, 3, 4, 4, 5];
$result = removeAllDuplicates($arr);
echo json_encode($result); // [1, 2, 3, 4, 5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment