Скрипт який дозволяє визначити яка за рахунком є поточна пара. - 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.
Result of php executing
Full code of Скрипт який дозволяє визначити яка за рахунком є поточна пара..php
- <?php
- $currentTimestamp = time();
- $lectureTimes = [
- strtotime('08:30:00'), // Перша пара
- strtotime('10:05:00'), // Друга пара
- strtotime('11:40:00'), // Третя пара
- strtotime('13:15:00'), // Четверта пара
- strtotime('14:50:00'), // П'ята пара
- strtotime('16:25:00') // Шоста пара
- ];
- $currentLecture = false;
- foreach ($lectureTimes as $index => $lectureTime) {
- if ($currentTimestamp < $lectureTime) {
- $currentLecture = $index + 1;
- break;
- }
- }
- if ($currentLecture !== false) {
- echo "Зараз $currentLecture-а пара";
- } else {
- echo "Зараз немає пари";
- }
- ?>