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); } echo json_encode($new_holidays,true);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/JGF5Q
function name:  (null)
number of ops:  20
compiled vars:  !0 = $response, !1 = $new_holidays, !2 = $employee
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'json_decode'
          1        SEND_VAL                                                 '%5B%7B%22firstname%22%3A%22system%22%2C%22lastname%22%3A%22system%22%2C%22id_employee%22%3A%2224040%22%2C%22schedule%22%3A%7B%222014-07-01%22%3A%7B%22text%22%3A%22OFF%22%2C%22id_event%22%3A%2222%22%2C%22event_name%22%3A%22off%22%2C%22color%22%3A%22AAAAAA%22%2C%22is_work%22%3Afalse%2C%22details%22%3A%5B%5D%7D%2C%222014-07-02%22%3A%7B%22text%22%3A%22OFF%22%2C%22id_event%22%3A%2222%22%2C%22event_name%22%3A%22off%22%2C%22color%22%3A%22AAAAAA%22%2C%22is_work%22%3Afalse%2C%22details%22%3A%5B%5D%7D%2C%222014-07-03%22%3A%7B%22text%22%3A%22OFF%22%2C%22id_event%22%3A%2222%22%2C%22event_name%22%3A%22off%22%2C%22color%22%3A%22AAAAAA%22%2C%22is_work%22%3Afalse%2C%22details%22%3A%5B%5D%7D%2C%222014-07-04%22%3A%7B%22text%22%3A%22OFF%22%2C%22id_event%22%3A%2222%22%2C%22event_name%22%3A%22off%22%2C%22color%22%3A%22AAAAAA%22%2C%22is_work%22%3Afalse%2C%22details%22%3A%5B%5D%7D%2C%222014-07-05%22%3A%7B%22text%22%3A%22OFF%22%2C%22id_event%22%3A%2222%22%2C%22event_name%22%3A%22off%22%2C%22color%22%3A%22AAAAAA%22%2C%22is_work%22%3Afalse%2C%22details%22%3A%5B%5D%7D%2C%222014-07-06%22%3A%7B%22text%22%3A%22OFF%22%2C%22id_event%22%3A%2222%22%2C%22event_name%22%3A%22off%22%2C%22color%22%3A%22AAAAAA%22%2C%22is_work%22%3Afalse%2C%22details%22%3A%5B%5D%7D%2C%222014-07-07%22%3A%7B%22text%22%3A%22OFF%22%2C%22id_event%22%3A%2222%22%2C%22event_name%22%3A%22off%22%2C%22color%22%3A%22AAAAAA%22%2C%22is_work%22%3Afalse%2C%22details%22%3A%5B%5D%7D%7D%7D%2C%7B%22firstname%22%3A%22amira%22%2C%22lastname%22%3A%22turki%22%2C%22id_employee%22%3A%2228472%22%2C%22schedule%22%3A%7B%222014-07-01%22%3A%7B%22text%22%3A%227h30-17h%22%2C%22id_event%22%3A%221%22%2C%22event_name%22%3A%22planifi%5Cu00e9%22%2C%22color%22%3A%22FFFFFF%22%2C%22is_work%22%3Atrue%2C%22details%22%3A%5B%7B%22event_name%22%3A%22planifi%5Cu00e9%22%2C%22id_event%22%3A%221%22%2C%22is_work%22%3A%221%22%2C%22start%22%3A1404192600%2C%22end%22%3A1404226800%7D%5D%7D%2C%222014-07-02%22%3A%7B%22text%22%3A%227h30-17h%22%2C%22id_event%22%3A%221%22%2C%22event_name%22%3A%22planifi%5Cu00e9%22%2C%22color%22%3A%22FFFFFF%22%2C%22is_work%22%3Atrue%2C%22details%22%3A%5B%7B%22event_name%22%3A%22planifi%5Cu00e9%22%2C%22id_event%22%3A%221%22%2C%22is_work%22%3A%221%22%2C%22start%22%3A1404279000%2C%22end%22%3A1404313200%7D%5D%7D%2C%222014-07-03%22%3A%7B%22text%22%3A%227h30-17h%22%2C%22id_event%22%3A%221%22%2C%22event_name%22%3A%22planifi%5Cu00e9%22%2C%22color%22%3A%22FFFFFF%22%2C%22is_work%22%3Atrue%2C%22details%22%3A%5B%7B%22event_name%22%3A%22planifi%5Cu00e9%22%2C%22id_event%22%3A%221%22%2C%22is_work%22%3A%221%22%2C%22start%22%3A1404365400%2C%22end%22%3A1404399600%7D%5D%7D%2C%222014-07-04%22%3A%7B%22text%22%3A%227h30-17h%22%2C%22id_event%22%3A%221%22%2C%22event_name%22%3A%22planifi%5Cu00e9%22%2C%22color%22%3A%22FFFFFF%22%2C%22is_work%22%3Atrue%2C%22details%22%3A%5B%7B%22event_name%22%3A%22planifi%5Cu00e9%22%2C%22id_event%22%3A%221%22%2C%22is_work%22%3A%221%22%2C%22start%22%3A1404451800%2C%22end%22%3A1404486000%7D%5D%7D%2C%222014-07-05%22%3A%7B%22text%22%3A%22REPOS%22%2C%22id_event%22%3A%2220%22%2C%22event_name%22%3A%22repos%22%2C%22color%22%3A%22FFFFAA%22%2C%22is_work%22%3Afalse%2C%22details%22%3A%5B%5D%7D%2C%222014-07-06%22%3A%7B%22text%22%3A%22REPOS%22%2C%22id_event%22%3A%2220%22%2C%22event_name%22%3A%22repos%22%2C%22color%22%3A%22FFFFAA%22%2C%22is_work%22%3Afalse%2C%22details%22%3A%5B%5D%7D%2C%222014-07-07%22%3A%7B%22text%22%3A%227h30-17h%22%2C%22id_event%22%3A%221%22%2C%22event_name%22%3A%22planifi%5Cu00e9%22%2C%22color%22%3A%22FFFFFF%22%2C%22is_work%22%3Atrue%2C%22details%22%3A%5B%7B%22event_name%22%3A%22planifi%5Cu00e9%22%2C%22id_event%22%3A%221%22%2C%22is_work%22%3A%221%22%2C%22start%22%3A1404711000%2C%22end%22%3A1404745200%7D%5D%7D%7D%7D%5D'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !0, $3
   13     5        ASSIGN                                                   !1, <array>
   15     6      > FE_RESET_R                                       $6      !0, ->13
          7    > > FE_FETCH_R                                               $6, !2, ->13
   16     8    >   INIT_FCALL                                               'extract_holidays'
          9        SEND_VAR                                                 !2
         10        SEND_VAR                                                 !1
         11        DO_FCALL                                      0          
   15    12      > JMP                                                      ->7
         13    >   FE_FREE                                                  $6
   19    14        INIT_FCALL                                               'json_encode'
         15        SEND_VAR                                                 !1
         16        SEND_VAL                                                 <true>
         17        DO_ICALL                                         $8      
         18        ECHO                                                     $8
         19      > RETURN                                                   1

Function extract_holidays:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JGF5Q
function name:  extract_holidays
number of ops:  12
compiled vars:  !0 = $employee, !1 = $new_holidays
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        FETCH_DIM_R                                      ~3      !0, 'firstname'
          3        CONCAT                                           ~4      ~3, '+'
          4        FETCH_DIM_R                                      ~5      !0, 'lastname'
          5        CONCAT                                           ~6      ~4, ~5
          6        INIT_ARRAY                                       ~7      ~6, 'name'
    7     7        ADD_ARRAY_ELEMENT                                ~7      '2014-01-01', 'startDate'
    8     8        ADD_ARRAY_ELEMENT                                ~7      '2014-01-07', 'endDate'
    5     9        ASSIGN_DIM                                               !1
    8    10        OP_DATA                                                  ~7
   10    11      > RETURN                                                   null

End of function extract_holidays

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.18 ms | 1403 KiB | 18 Q