How can regular expressions be used to split strings in PHP?

Regular expressions can be used in PHP to split strings by defining a pattern to match the delimiter. The preg_split() function can be used to split a string based on a regular expression pattern. By using regular expressions, you can split strings based on specific criteria such as whitespace, commas, or any other custom delimiter.

$string = "apple,orange,banana";
$delimiter = ',';
$words = preg_split("/$delimiter/", $string);

foreach ($words as $word) {
    echo $word . "\n";
}