How can the explode() function be utilized to separate a string into multiple parts in PHP?

To separate a string into multiple parts in PHP, you can use the explode() function. This function takes a delimiter and a string as input, and returns an array of substrings that were separated by the delimiter. This is useful when you have a string with multiple values separated by a common character, such as a comma or space, and you want to extract each value individually.

$string = "apple,banana,orange";
$fruits = explode(",", $string);

foreach($fruits as $fruit) {
    echo $fruit . "<br>";
}