3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); // change every X hours define('EVERY', 2); // here we have the images $images = [ 'image1.png', 'image2.png', 'image3.png', 'image4.png', 'image5.png', 'image6.png' ]; // anonymous function to get the current Image $imageFor = function ($hour) use ($images) { $index = $hour / EVERY % count($images); return $images[$index]; }; // output for all the hours for ($i = 0; $i < 24; $i++) echo "$i\t", $imageFor($i), PHP_EOL; $currentHour = date('G'); echo "[$currentHour] Now showing Image: ", $imageFor($currentHour);

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
171.89 ms | 3561 KiB | 13 Q