3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getClosest($search, $arr) { $closest = null; foreach ($arr as $item) { if ($closest === null || abs($search - $closest) > abs($item - $search)) { $closest = $item; } } return $closest; } $days = array ('monday','wednesday','saturday'); for($i=0; $i<sizeof($days);$i++){ $d[$i]=strtotime($days[$i]); } print_r($d); die();

preferences:
39.34 ms | 402 KiB | 5 Q