3v4l.org

run code in 300+ PHP versions simultaneously
<?php $w = date("w"); $array = array( 0 => 1, 1 => 2, 2 => 3, 3 => 4, 4 => 5 ); function find(array $array, $needle) { $last = null; // return value if $pricing array is empty foreach ($array as $key => $value) { if ($key >= $needle) { return $value; } $last = $key; } return $last; } if(in_array($w, $array)) { echo find($array, $w); }

preferences:
61.69 ms | 402 KiB | 5 Q