How can explode be used in PHP to extract specific values from a string?

To extract specific values from a string in PHP, you can use the explode function to split the string into an array based on a specified delimiter. Once the string is split, you can access the specific values you need by referencing their respective array indexes.

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

echo $values[0]; // Output: apple
echo $values[2]; // Output: banana