3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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); var_dump($response); $new_holidays = []; /* foreach($response as $employee) { extract_holidays($employee, $new_holidays); } echo json_encode($new_holidays,true); */
Output for 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(2) { [0]=> array(4) { ["firstname"]=> string(6) "system" ["lastname"]=> string(6) "system" ["id_employee"]=> string(5) "24040" ["schedule"]=> array(7) { ["2014-07-01"]=> array(6) { ["text"]=> string(3) "OFF" ["id_event"]=> string(2) "22" ["event_name"]=> string(3) "off" ["color"]=> string(6) "AAAAAA" ["is_work"]=> bool(false) ["details"]=> array(0) { } } ["2014-07-02"]=> array(6) { ["text"]=> string(3) "OFF" ["id_event"]=> string(2) "22" ["event_name"]=> string(3) "off" ["color"]=> string(6) "AAAAAA" ["is_work"]=> bool(false) ["details"]=> array(0) { } } ["2014-07-03"]=> array(6) { ["text"]=> string(3) "OFF" ["id_event"]=> string(2) "22" ["event_name"]=> string(3) "off" ["color"]=> string(6) "AAAAAA" ["is_work"]=> bool(false) ["details"]=> array(0) { } } ["2014-07-04"]=> array(6) { ["text"]=> string(3) "OFF" ["id_event"]=> string(2) "22" ["event_name"]=> string(3) "off" ["color"]=> string(6) "AAAAAA" ["is_work"]=> bool(false) ["details"]=> array(0) { } } ["2014-07-05"]=> array(6) { ["text"]=> string(3) "OFF" ["id_event"]=> string(2) "22" ["event_name"]=> string(3) "off" ["color"]=> string(6) "AAAAAA" ["is_work"]=> bool(false) ["details"]=> array(0) { } } ["2014-07-06"]=> array(6) { ["text"]=> string(3) "OFF" ["id_event"]=> string(2) "22" ["event_name"]=> string(3) "off" ["color"]=> string(6) "AAAAAA" ["is_work"]=> bool(false) ["details"]=> array(0) { } } ["2014-07-07"]=> array(6) { ["text"]=> string(3) "OFF" ["id_event"]=> string(2) "22" ["event_name"]=> string(3) "off" ["color"]=> string(6) "AAAAAA" ["is_work"]=> bool(false) ["details"]=> array(0) { } } } } [1]=> array(4) { ["firstname"]=> string(5) "amira" ["lastname"]=> string(5) "turki" ["id_employee"]=> string(5) "28472" ["schedule"]=> array(7) { ["2014-07-01"]=> array(6) { ["text"]=> string(8) "7h30-17h" ["id_event"]=> string(1) "1" ["event_name"]=> string(9) "planifié" ["color"]=> string(6) "FFFFFF" ["is_work"]=> bool(true) ["details"]=> array(1) { [0]=> array(5) { ["event_name"]=> string(9) "planifié" ["id_event"]=> string(1) "1" ["is_work"]=> string(1) "1" ["start"]=> int(1404192600) ["end"]=> int(1404226800) } } } ["2014-07-02"]=> array(6) { ["text"]=> string(8) "7h30-17h" ["id_event"]=> string(1) "1" ["event_name"]=> string(9) "planifié" ["color"]=> string(6) "FFFFFF" ["is_work"]=> bool(true) ["details"]=> array(1) { [0]=> array(5) { ["event_name"]=> string(9) "planifié" ["id_event"]=> string(1) "1" ["is_work"]=> string(1) "1" ["start"]=> int(1404279000) ["end"]=> int(1404313200) } } } ["2014-07-03"]=> array(6) { ["text"]=> string(8) "7h30-17h" ["id_event"]=> string(1) "1" ["event_name"]=> string(9) "planifié" ["color"]=> string(6) "FFFFFF" ["is_work"]=> bool(true) ["details"]=> array(1) { [0]=> array(5) { ["event_name"]=> string(9) "planifié" ["id_event"]=> string(1) "1" ["is_work"]=> string(1) "1" ["start"]=> int(1404365400) ["end"]=> int(1404399600) } } } ["2014-07-04"]=> array(6) { ["text"]=> string(8) "7h30-17h" ["id_event"]=> string(1) "1" ["event_name"]=> string(9) "planifié" ["color"]=> string(6) "FFFFFF" ["is_work"]=> bool(true) ["details"]=> array(1) { [0]=> array(5) { ["event_name"]=> string(9) "planifié" ["id_event"]=> string(1) "1" ["is_work"]=> string(1) "1" ["start"]=> int(1404451800) ["end"]=> int(1404486000) } } } ["2014-07-05"]=> array(6) { ["text"]=> string(5) "REPOS" ["id_event"]=> string(2) "20" ["event_name"]=> string(5) "repos" ["color"]=> string(6) "FFFFAA" ["is_work"]=> bool(false) ["details"]=> array(0) { } } ["2014-07-06"]=> array(6) { ["text"]=> string(5) "REPOS" ["id_event"]=> string(2) "20" ["event_name"]=> string(5) "repos" ["color"]=> string(6) "FFFFAA" ["is_work"]=> bool(false) ["details"]=> array(0) { } } ["2014-07-07"]=> array(6) { ["text"]=> string(8) "7h30-17h" ["id_event"]=> string(1) "1" ["event_name"]=> string(9) "planifié" ["color"]=> string(6) "FFFFFF" ["is_work"]=> bool(true) ["details"]=> array(1) { [0]=> array(5) { ["event_name"]=> string(9) "planifié" ["id_event"]=> string(1) "1" ["is_work"]=> string(1) "1" ["start"]=> int(1404711000) ["end"]=> int(1404745200) } } } } } }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/rslpI on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/rslpI on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/rslpI on line 5
Process exited with code 255.