3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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();
based on s6XYB
Output for 5.3.21 - 5.4.45, 5.6.28, 7.0.20 - 7.2.0
Array ( [0] => 1451862000 [1] => 1451430000 [2] => 1451689200 )
Output for 7.0.6
Array ( [0] => 1463954400 [1] => 1464127200 [2] => 1463781600 )
Output for 7.0.5
Array ( [0] => 1459720800 [1] => 1459893600 [2] => 1460152800 )
Output for 7.0.4
Array ( [0] => 1457910000 [1] => 1458082800 [2] => 1457737200 )
Output for 5.5.32, 7.0.3
Array ( [0] => 1458514800 [1] => 1458687600 [2] => 1458342000 )
Output for 7.0.2
Array ( [0] => 1459116000 [1] => 1458687600 [2] => 1458946800 )
Output for 7.0.1
Array ( [0] => 1459116000 [1] => 1459288800 [2] => 1458946800 )
Output for 5.6.16, 7.0.0
Array ( [0] => 1459116000 [1] => 1459288800 [2] => 1459548000 )
Output for 5.6.21
Array ( [0] => 1462140000 [1] => 1462312800 [2] => 1462572000 )
Output for 5.5.34, 5.6.20
Array ( [0] => 1460325600 [1] => 1460498400 [2] => 1460757600 )
Output for 5.5.33, 5.6.19
Array ( [0] => 1457910000 [1] => 1457478000 [2] => 1457737200 )
Output for 5.6.18
Array ( [0] => 1458514800 [1] => 1458082800 [2] => 1458342000 )
Output for 5.5.31, 5.6.17
Array ( [0] => 1458514800 [1] => 1458687600 [2] => 1458946800 )
Output for 5.6.15
Array ( [0] => 1459720800 [1] => 1459288800 [2] => 1459548000 )
Output for 5.6.13 - 5.6.14
Array ( [0] => 1460930400 [1] => 1461103200 [2] => 1460757600 )
Output for 5.6.12
Array ( [0] => 1461535200 [1] => 1461103200 [2] => 1461362400 )
Output for 5.6.10 - 5.6.11
Array ( [0] => 1461535200 [1] => 1461708000 [2] => 1461967200 )
Output for 5.5.26, 5.6.9
Array ( [0] => 1462140000 [1] => 1461708000 [2] => 1461967200 )
Output for 5.5.25, 5.6.8
Array ( [0] => 1462140000 [1] => 1462312800 [2] => 1461967200 )
Output for 5.5.35
Array ( [0] => 1463954400 [1] => 1464127200 [2] => 1464386400 )
Output for 5.5.30
Array ( [0] => 1459720800 [1] => 1459893600 [2] => 1459548000 )
Output for 5.5.29
Array ( [0] => 1460930400 [1] => 1461103200 [2] => 1461362400 )
Output for 5.5.27 - 5.5.28
Array ( [0] => 1461535200 [1] => 1461708000 [2] => 1461362400 )
Output for 5.5.24
Array ( [0] => 1464559200 [1] => 1464127200 [2] => 1464386400 )