How can PHP's explode function be used to extract specific data from a string?
When using PHP's explode function to extract specific data from a string, you can split the string into an array based on a specified delimiter. Once the string is split, you can access the specific data you need by referring to the corresponding index in the resulting array.
$string = "John,Doe,30,New York";
$data = explode(",", $string);
$firstName = $data[0];
$lastName = $data[1];
$age = $data[2];
$city = $data[3];
echo "First Name: " . $firstName . "<br>";
echo "Last Name: " . $lastName . "<br>";
echo "Age: " . $age . "<br>";
echo "City: " . $city;