3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sessions=json_decode('[ {"heure_debut":"08:00","heure_fin":"09:00","attr":"test"}, {"heure_debut":"09:10","heure_fin":"10:00"}, {"heure_debut":"10:00","heure_fin":"11:00"}, {"heure_debut":"11:00","heure_fin":"12:00","bla":"bla"}, {"heure_debut":"12:00","heure_fin":"13:00"}, {"heure_debut":"13:00","heure_fin":"14:30"} ]',TRUE); function uncut_seances($sessions) { $result = NULL; if(is_array($sessions) AND count($sessions)>0 AND isset($sessions[0]["heure_debut"]) AND isset($sessions[0]["heure_fin"])) { $real_sessions[] = $sessions[0]; $j = 0; for ($i = 1; $i < count($sessions); $i++) { if ($real_sessions[$j]["heure_fin"] === $sessions[$i]["heure_debut"]) { $real_sessions[$j]["heure_fin"] = $sessions[$i]["heure_fin"]; } else { $real_sessions[] = $sessions[$i]; $j++; } } $result = $real_sessions; } return $result; } print_r(uncut_seances($sessions));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qMRHR
function name:  (null)
number of ops:  12
compiled vars:  !0 = $sessions
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'json_decode'
          1        SEND_VAL                                                 '%5B%0A%7B%22heure_debut%22%3A%2208%3A00%22%2C%22heure_fin%22%3A%2209%3A00%22%2C%22attr%22%3A%22test%22%7D%2C%0A++++++++%7B%22heure_debut%22%3A%2209%3A10%22%2C%22heure_fin%22%3A%2210%3A00%22%7D%2C%0A++++++++%7B%22heure_debut%22%3A%2210%3A00%22%2C%22heure_fin%22%3A%2211%3A00%22%7D%2C%0A%7B%22heure_debut%22%3A%2211%3A00%22%2C%22heure_fin%22%3A%2212%3A00%22%2C%22bla%22%3A%22bla%22%7D%2C%0A++++++++%7B%22heure_debut%22%3A%2212%3A00%22%2C%22heure_fin%22%3A%2213%3A00%22%7D%2C%0A++++++++%7B%22heure_debut%22%3A%2213%3A00%22%2C%22heure_fin%22%3A%2214%3A30%22%7D%0A%5D'
    9     2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $1      
    2     4        ASSIGN                                                   !0, $1
   33     5        INIT_FCALL                                               'print_r'
          6        INIT_FCALL                                               'uncut_seances'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0  $3      
          9        SEND_VAR                                                 $3
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function uncut_seances:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 43
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 22
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 34
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 22
Branch analysis from position: 42
Branch analysis from position: 22
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 22
Branch analysis from position: 42
Branch analysis from position: 22
Branch analysis from position: 43
Branch analysis from position: 15
Branch analysis from position: 11
Branch analysis from position: 7
filename:       /in/qMRHR
function name:  uncut_seances
number of ops:  45
compiled vars:  !0 = $sessions, !1 = $result, !2 = $real_sessions, !3 = $j, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        ASSIGN                                                   !1, null
   13     2        TYPE_CHECK                                  128  ~6      !0
          3      > JMPZ_EX                                          ~6      ~6, ->7
          4    >   COUNT                                            ~7      !0
          5        IS_SMALLER                                       ~8      0, ~7
          6        BOOL                                             ~6      ~8
          7    > > JMPZ_EX                                          ~6      ~6, ->11
          8    >   FETCH_DIM_IS                                     ~9      !0, 0
          9        ISSET_ISEMPTY_DIM_OBJ                         0  ~10     ~9, 'heure_debut'
         10        BOOL                                             ~6      ~10
         11    > > JMPZ_EX                                          ~6      ~6, ->15
         12    >   FETCH_DIM_IS                                     ~11     !0, 0
         13        ISSET_ISEMPTY_DIM_OBJ                         0  ~12     ~11, 'heure_fin'
         14        BOOL                                             ~6      ~12
         15    > > JMPZ                                                     ~6, ->43
   15    16    >   FETCH_DIM_R                                      ~14     !0, 0
         17        ASSIGN_DIM                                               !2
         18        OP_DATA                                                  ~14
   16    19        ASSIGN                                                   !3, 0
   18    20        ASSIGN                                                   !4, 1
         21      > JMP                                                      ->39
   20    22    >   FETCH_DIM_R                                      ~17     !2, !3
         23        FETCH_DIM_R                                      ~18     ~17, 'heure_fin'
         24        FETCH_DIM_R                                      ~19     !0, !4
         25        FETCH_DIM_R                                      ~20     ~19, 'heure_debut'
         26        IS_IDENTICAL                                             ~18, ~20
         27      > JMPZ                                                     ~21, ->34
   22    28    >   FETCH_DIM_R                                      ~24     !0, !4
         29        FETCH_DIM_R                                      ~25     ~24, 'heure_fin'
         30        FETCH_DIM_W                                      $22     !2, !3
         31        ASSIGN_DIM                                               $22, 'heure_fin'
         32        OP_DATA                                                  ~25
         33      > JMP                                                      ->38
   24    34    >   FETCH_DIM_R                                      ~27     !0, !4
         35        ASSIGN_DIM                                               !2
         36        OP_DATA                                                  ~27
   25    37        PRE_INC                                                  !3
   18    38    >   PRE_INC                                                  !4
         39    >   COUNT                                            ~30     !0
         40        IS_SMALLER                                               !4, ~30
         41      > JMPNZ                                                    ~31, ->22
   28    42    >   ASSIGN                                                   !1, !2
   30    43    > > RETURN                                                   !1
   31    44*     > RETURN                                                   null

End of function uncut_seances

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.25 ms | 1394 KiB | 18 Q