How can the explode() function be used to separate values in a string in PHP?

The explode() function in PHP can be used to separate values in a string based on a specified delimiter. This is useful when you have a string containing multiple values that are separated by a common character, such as a comma or space. By using explode(), you can split the string into an array of individual values that can be accessed and manipulated separately.

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

foreach($values as $value){
    echo $value . "<br>";
}