Скрипт який дозволяє визначити яка за рахунком є поточна пара. - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.

Name: Скрипт який дозволяє визначити яка за рахунком є поточна пара. fullscreencopydownloadembedprint


Your result can be seen below.

Result of php executing





Full code of Скрипт який дозволяє визначити яка за рахунком є поточна пара..php

  1. <?php
  2.  
  3. $currentTimestamp = time();
  4.  
  5.  
  6. $lectureTimes = [
  7.     strtotime('08:30:00'), // Перша пара
  8.     strtotime('10:05:00'), // Друга пара
  9.     strtotime('11:40:00'), // Третя пара
  10.     strtotime('13:15:00'), // Четверта пара
  11.     strtotime('14:50:00'),  // П'ята пара
  12.     strtotime('16:25:00')  // Шоста пара
  13. ];
  14.  
  15.  
  16. $currentLecture = false;
  17.  
  18. foreach ($lectureTimes as $index => $lectureTime) {
  19.     if ($currentTimestamp < $lectureTime) {
  20.         $currentLecture = $index + 1;
  21.         break;
  22.     }
  23. }
  24.  
  25.  
  26. if ($currentLecture !== false) {
  27.     echo "Зараз $currentLecture-а пара";
  28. } else {
  29.     echo "Зараз немає пари";
  30. }
  31. ?>
  32.  
File Description
  • Скрипт який дозволяє визначити яка за рахунком є поточна пара.
  • PHP Code
  • 14 Sep-2023
  • 723 Bytes
You can Share it: