What PHP function can be used to separate segments of a date into separate variables?
To separate segments of a date into separate variables, you can use the `explode()` function in PHP. This function allows you to split a string into an array based on a specified delimiter. In the case of a date, you can use the delimiter of "-" or "/" to separate the year, month, and day into individual variables.
$date = "2022-12-31";
$dateSegments = explode("-", $date);
$year = $dateSegments[0];
$month = $dateSegments[1];
$day = $dateSegments[2];
echo "Year: " . $year . "<br>";
echo "Month: " . $month . "<br>";
echo "Day: " . $day . "<br>";