3v4l.org

run code in 300+ PHP versions simultaneously
<?php function extract_holidays($employee /* Array */, $new_holidays /* Array */) { $new_holidays[] = [ "name" => $employee["firstname"].' '.$employee["lastname"], "startDate" => '2014-01-01', "endDate" => '2014-01-07' ]; } $response = json_decode('[{"firstname":"system","lastname":"system","id_employee":"24040","schedule":{"2014-07-01":{"text":"OFF","id_event":"22","event_name":"off","color":"AAAAAA","is_work":false,"details":[]},"2014-07-02":{"text":"OFF","id_event":"22","event_name":"off","color":"AAAAAA","is_work":false,"details":[]},"2014-07-03":{"text":"OFF","id_event":"22","event_name":"off","color":"AAAAAA","is_work":false,"details":[]},"2014-07-04":{"text":"OFF","id_event":"22","event_name":"off","color":"AAAAAA","is_work":false,"details":[]},"2014-07-05":{"text":"OFF","id_event":"22","event_name":"off","color":"AAAAAA","is_work":false,"details":[]},"2014-07-06":{"text":"OFF","id_event":"22","event_name":"off","color":"AAAAAA","is_work":false,"details":[]},"2014-07-07":{"text":"OFF","id_event":"22","event_name":"off","color":"AAAAAA","is_work":false,"details":[]}}},{"firstname":"amira","lastname":"turki","id_employee":"28472","schedule":{"2014-07-01":{"text":"7h30-17h","id_event":"1","event_name":"planifi\u00e9","color":"FFFFFF","is_work":true,"details":[{"event_name":"planifi\u00e9","id_event":"1","is_work":"1","start":1404192600,"end":1404226800}]},"2014-07-02":{"text":"7h30-17h","id_event":"1","event_name":"planifi\u00e9","color":"FFFFFF","is_work":true,"details":[{"event_name":"planifi\u00e9","id_event":"1","is_work":"1","start":1404279000,"end":1404313200}]},"2014-07-03":{"text":"7h30-17h","id_event":"1","event_name":"planifi\u00e9","color":"FFFFFF","is_work":true,"details":[{"event_name":"planifi\u00e9","id_event":"1","is_work":"1","start":1404365400,"end":1404399600}]},"2014-07-04":{"text":"7h30-17h","id_event":"1","event_name":"planifi\u00e9","color":"FFFFFF","is_work":true,"details":[{"event_name":"planifi\u00e9","id_event":"1","is_work":"1","start":1404451800,"end":1404486000}]},"2014-07-05":{"text":"REPOS","id_event":"20","event_name":"repos","color":"FFFFAA","is_work":false,"details":[]},"2014-07-06":{"text":"REPOS","id_event":"20","event_name":"repos","color":"FFFFAA","is_work":false,"details":[]},"2014-07-07":{"text":"7h30-17h","id_event":"1","event_name":"planifi\u00e9","color":"FFFFFF","is_work":true,"details":[{"event_name":"planifi\u00e9","id_event":"1","is_work":"1","start":1404711000,"end":1404745200}]}}}]',true); $new_holidays = []; foreach($response as $employee) { extract_holidays($employee, $new_holidays); } var_dump($new_holidays); // echo json_encode($new_holidays,true);
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
array(0) { }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/goFc6 on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/goFc6 on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/goFc6 on line 5
Process exited with code 255.

preferences:
363.52 ms | 401 KiB | 460 Q