How does the explode function in PHP handle different delimiters and separators?

When using the explode function in PHP, you can specify a single delimiter to split a string into an array. However, if you need to handle different delimiters or separators, you can use the preg_split function with a regular expression pattern to split the string accordingly.

// Example of using preg_split to handle different delimiters and separators
$string = "apple,orange;banana|grape";
$delimiter = '/[,;|]/';
$parts = preg_split($delimiter, $string);

print_r($parts);