How can the combination of explode, filter_var_array, array_map, and array_filter be utilized to efficiently extract and manipulate data from a string in PHP?

To efficiently extract and manipulate data from a string in PHP, you can use the combination of explode, filter_var_array, array_map, and array_filter functions. First, explode the string into an array of values. Then, use filter_var_array to filter out only the values that meet certain criteria. Next, use array_map to manipulate each value as needed. Finally, use array_filter to remove any unwanted values from the array.

$string = "John,Doe,30,email@example.com";
$data = explode(",", $string);

$filteredData = filter_var_array($data, FILTER_VALIDATE_EMAIL);

$manipulatedData = array_map(function($value) {
    return strtoupper($value);
}, $filteredData);

$finalData = array_filter($manipulatedData);

print_r($finalData);