[insert_php]
loadHTML($response);
// Find the vakit-top-wrapper element and extract its values
$vakitTopWrapper = $dom->getElementById('vakit-top-wrapper');
if ($vakitTopWrapper) {
// Extract prayer times
$prayerTimes = $vakitTopWrapper->getElementsByTagName('td');
// Extract remaining time and local date/time
$remainingTime = $dom->getElementById('left-time')->nodeValue;
$localTime = $dom->getElementById('local-time')->nodeValue;
$localDate = $dom->getElementById('local-date')->nodeValue;
// Format the prayer times, remaining time, local date and time
$prayerTimesFormatted = [];
foreach ($prayerTimes as $prayerTime) {
$prayerTimesFormatted[] = trim($prayerTime->nodeValue);
}
$remainingTimeFormatted = substr($remainingTime, 0, -3);
$localTimeFormatted = date('g:i A', strtotime($localTime));
$localDateFormat = 'j F Y'; // Format of local date
$localDateFormatted = date($localDateFormat, strtotime($localDate));
// Output the formatted values
echo '
Prayer Times: ' . implode(' | ', $prayerTimesFormatted) . '
'; echo 'Remaining Time: ' . $remainingTimeFormatted . '
'; echo 'Local Time: ' . $localTimeFormatted . '
'; echo 'Local Date: ' . $localDateFormatted . '
'; } else { echo 'Error: vakit-top-wrapper element not found'; } ?> [/insert_php]