In what situations would it be more efficient to use preg_split instead of regular expressions in PHP for string manipulation?

When you need to split a string into an array based on a delimiter, it may be more efficient to use preg_split instead of regular expressions in PHP. preg_split allows you to split a string using a regular expression pattern as the delimiter, which can be useful when the delimiter is more complex or variable.

$string = "apple, orange, banana";
$delimiter = "/,\s*/"; // regular expression pattern for comma followed by optional whitespace
$array = preg_split($delimiter, $string);

print_r($array);