How can the explode function be properly used to extract day, month, and year components from a date string in PHP?

To extract day, month, and year components from a date string in PHP, you can use the explode function to split the date string into an array based on a delimiter (such as "/"). Then, you can access the day, month, and year values from the resulting array.

$dateString = "10/25/2022";
$dateArray = explode("/", $dateString);
$day = $dateArray[1];
$month = $dateArray[0];
$year = $dateArray[2];

echo "Day: " . $day . "<br>";
echo "Month: " . $month . "<br>";
echo "Year: " . $year . "<br>";