Remove Duplicates from an Array: Write a PHP function to remove duplicate values from an array.

function removeDuplicates($arr) {
    return array_unique($arr);
}

// Example usage:
$array = [1, 2, 2, 3, 4, 4, 5];
print_r(removeDuplicates($array));

Related Posts

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Artificial Intelligence