What is the purpose of using the explode function in PHP and how can it be used to split a string into multiple substrings?

The explode function in PHP is used to split a string into multiple substrings based on a specified delimiter. This is useful when you have a string that contains multiple values separated by a common character, such as a comma or space, and you need to extract each value individually. By using explode, you can easily break the string into an array of substrings, making it easier to work with and manipulate the data.

// Example of using explode to split a string into multiple substrings
$string = "apple,banana,orange";
$fruits = explode(",", $string);

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