3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sessions=json_decode('[ {"heure_debut":"08:00","heure_fin":"09:00"}, {"heure_debut":"09:10","heure_fin":"10:00"}, {"heure_debut":"10:00","heure_fin":"11:00"}, {"heure_debut":"11:00","heure_fin":"12:00"}, {"heure_debut":"12:00","heure_fin":"13:00"}, {"heure_debut":"13:00","heure_fin":"14:30"} ]',TRUE); //print_r($sessions); $real_sessions[]=array("heure_debut"=>$sessions[0]["heure_debut"],"heure_fin"=>$sessions[0]["heure_fin"]); $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[]=array("heure_debut"=>$sessions[$i]["heure_debut"],"heure_fin"=>$sessions[$i]["heure_fin"]);; $j++; } } print_r($real_sessions);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 16
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 28
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 16
Branch analysis from position: 41
Branch analysis from position: 16
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 16
Branch analysis from position: 41
Branch analysis from position: 16
filename:       /in/3QnZj
function name:  (null)
number of ops:  45
compiled vars:  !0 = $sessions, !1 = $real_sessions, !2 = $j, !3 = $i
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%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%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                                         $4      
    2     4        ASSIGN                                                   !0, $4
   14     5        FETCH_DIM_R                                      ~7      !0, 0
          6        FETCH_DIM_R                                      ~8      ~7, 'heure_debut'
          7        INIT_ARRAY                                       ~9      ~8, 'heure_debut'
          8        FETCH_DIM_R                                      ~10     !0, 0
          9        FETCH_DIM_R                                      ~11     ~10, 'heure_fin'
         10        ADD_ARRAY_ELEMENT                                ~9      ~11, 'heure_fin'
         11        ASSIGN_DIM                                               !1
         12        OP_DATA                                                  ~9
   15    13        ASSIGN                                                   !2, 0
   17    14        ASSIGN                                                   !3, 1
         15      > JMP                                                      ->38
   19    16    >   FETCH_DIM_R                                      ~14     !1, !2
         17        FETCH_DIM_R                                      ~15     ~14, 'heure_fin'
         18        FETCH_DIM_R                                      ~16     !0, !3
         19        FETCH_DIM_R                                      ~17     ~16, 'heure_debut'
         20        IS_IDENTICAL                                             ~15, ~17
         21      > JMPZ                                                     ~18, ->28
   21    22    >   FETCH_DIM_R                                      ~21     !0, !3
         23        FETCH_DIM_R                                      ~22     ~21, 'heure_fin'
         24        FETCH_DIM_W                                      $19     !1, !2
         25        ASSIGN_DIM                                               $19, 'heure_fin'
         26        OP_DATA                                                  ~22
         27      > JMP                                                      ->37
   23    28    >   FETCH_DIM_R                                      ~24     !0, !3
         29        FETCH_DIM_R                                      ~25     ~24, 'heure_debut'
         30        INIT_ARRAY                                       ~26     ~25, 'heure_debut'
         31        FETCH_DIM_R                                      ~27     !0, !3
         32        FETCH_DIM_R                                      ~28     ~27, 'heure_fin'
         33        ADD_ARRAY_ELEMENT                                ~26     ~28, 'heure_fin'
         34        ASSIGN_DIM                                               !1
         35        OP_DATA                                                  ~26
   24    36        PRE_INC                                                  !2
   17    37    >   PRE_INC                                                  !3
         38    >   COUNT                                            ~31     !0
         39        IS_SMALLER                                               !3, ~31
         40      > JMPNZ                                                    ~32, ->16
   28    41    >   INIT_FCALL                                               'print_r'
         42        SEND_VAR                                                 !1
         43        DO_ICALL                                                 
         44      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
186.31 ms | 1400 KiB | 17 Q