3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dates[] = array("date" => "2016-02-18 02:00:00", "duration" => "600"); // 10 mins $dates[] = array("date" => "2016-02-18 02:05:00", "duration" => "300"); // 5 mins $dates[] = array("date" => "2016-02-18 02:10:00", "duration" => "600"); $dates[] = array("date" => "2016-02-18 02:25:00", "duration" => "300"); $dates[] = array("date" => "2016-02-18 02:30:00", "duration" => "600"); $children = array("callum" => "1028", "daniel" => "1029"); $closeDate[] = array("date" => "2016-02-18 02:00:00", "duration" => "600"); // 10 mins function returnClosestDate($child){ global $initialLoop; global $closeDate; global $dates; foreach ($dates as $key => $date) { $dateToCompare = strtotime($date); $diff = $firstTime - $dateToCompare; if ($diff < 0) $diff *= -1; if (count($closeDate) == 0) { $closeDate[][$child] = array("date" => $date, "diff" => $diff); continue; } for ($x = 0; $x <= count($closeDate); $x++) { if(isset($closeDate[$x])){ if ($diff < $closeDate[$x][$child]["diff"]) { $closeDate[$x][$child] = array("date" => $date, "diff" => $diff); } } } //if(!alreadyExistInArray($closeDate, $date, $child)){ //if ($diff < $closeDate[$key-1]["diff"]) { //$closeDate[$key] = array("child" => $child, "date" => $date, "diff" => $diff); // } //} } echo "<pre>"; print_r($closeDate); echo "</pre>"; exit; } function alreadyExistInArray($closeDate, $date, $child){ foreach($closeDate as $key => $close){ if($close["child"] === $child) return true; } } foreach($children as $key => $child){ returnClosestDate($child); }
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: strtotime(): Argument #1 ($datetime) must be of type string, array given in /in/mjvJs:20 Stack trace: #0 /in/mjvJs(20): strtotime(Array) #1 /in/mjvJs(55): returnClosestDate('1028') #2 {main} thrown in /in/mjvJs on line 20
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
56.6 ms | 401 KiB | 8 Q