How can custom functions be created in PHP to achieve specific array manipulation tasks?

To create custom functions in PHP for specific array manipulation tasks, you can define a function that takes an array as a parameter, performs the desired manipulation, and then returns the modified array. This allows you to encapsulate the manipulation logic and reuse it throughout your code.

// Function to remove duplicates from an array
function removeDuplicates($array) {
    return array_unique($array);
}

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