3v4l.org

run code in 500+ PHP versions simultaneously
<?php function parseLog($log) { $lines = explode("\n", $log); $history = array(); foreach($lines as $key => $line) { if(strpos($line, 'commit') === 0 || $key + 1 == count($lines)){ if(!empty($commit)){ $commit['message'] = substr($commit['message'], 4); array_push($history, $commit); unset($commit); } $commit['hash'] = substr($line, strlen('commit') + 1); } else if(strpos($line, 'Author') === 0){ $commit['author'] = substr($line, strlen('Author:') + 1); } else if(strpos($line, 'Date') === 0){ $commit['date'] = substr($line, strlen('Date:') + 3); } elseif (strpos($line, 'Merge') === 0) { $commit['merge'] = substr($line, strlen('Merge:') + 1); $commit['merge'] = explode(' ', $commit['merge']); } else { if(isset($commit['message'])) { $commit['message'] .= $line; } else { $commit['message'] = $line; } } } return $history; } $gLog = <<< 'EOD' commit 56ed4ea370bd334580adb00d7c15f32e67b8164f (HEAD -> dev, origin/dev) Author: Alexander Jank <alex@zeraton.de> Date: Fri Feb 19 09:23:51 2021 +0100 chore(tools): configure eslint commit 6fa00559d5e9f1d71efe1382bfc21200fdb79fb1 Author: Alexander Jank <alex@zeraton.de> Date: Fri Feb 19 09:18:43 2021 +0100 feat(gql): add codegen commit d07218637cc7315d9b27e6a726a0eb43f336278b Author: Alexander Jank <alex@zeraton.de> Date: Wed Feb 17 12:11:43 2021 +0100 chore(git): remove files commit c12bb8e763cacc6ea2ef543462dc61d032c30ad4 Author: Alexander Jank <alex@zeraton.de> Date: Wed Feb 17 12:10:33 2021 +0100 feat(backend): add schemas commit 19a17d077c703ba5a1091272c1af1cb9a8e25865 Author: Alexander Jank <alex@zeraton.de> Date: Wed Feb 17 10:24:14 2021 +0100 feat(backend): add EOD; var_dump(parseLog($gLog));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7eGFF
function name:  (null)
number of ops:  8
compiled vars:  !0 = $gLog
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   32     0  E >   ASSIGN                                                       !0, 'commit+56ed4ea370bd334580adb00d7c15f32e67b8164f+%28HEAD+-%3E+dev%2C+origin%2Fdev%29%0AAuthor%3A+Alexander+Jank+%3Calex%40zeraton.de%3E%0ADate%3A+++Fri+Feb+19+09%3A23%3A51+2021+%2B0100%0A%0A++++chore%28tools%29%3A+configure+eslint%0A%0Acommit+6fa00559d5e9f1d71efe1382bfc21200fdb79fb1%0AAuthor%3A+Alexander+Jank+%3Calex%40zeraton.de%3E%0ADate%3A+++Fri+Feb+19+09%3A18%3A43+2021+%2B0100%0A%0A++++feat%28gql%29%3A+add+codegen%0A%0Acommit+d07218637cc7315d9b27e6a726a0eb43f336278b%0AAuthor%3A+Alexander+Jank+%3Calex%40zeraton.de%3E%0ADate%3A+++Wed+Feb+17+12%3A11%3A43+2021+%2B0100%0A%0A++++chore%28git%29%3A+remove+files%0A%0Acommit+c12bb8e763cacc6ea2ef543462dc61d032c30ad4%0AAuthor%3A+Alexander+Jank+%3Calex%40zeraton.de%3E%0ADate%3A+++Wed+Feb+17+12%3A10%3A33+2021+%2B0100%0A%0A++++feat%28backend%29%3A+add+schemas%0A%0Acommit+19a17d077c703ba5a1091272c1af1cb9a8e25865%0AAuthor%3A+Alexander+Jank+%3Calex%40zeraton.de%3E%0ADate%3A+++Wed+Feb+17+10%3A24%3A14+2021+%2B0100%0A%0A++++feat%28backend%29%3A+add%0A'
   65     1        INIT_FCALL                                                   'var_dump'
          2        INIT_FCALL                                                   'parselog'
          3        SEND_VAR                                                     !0
          4        DO_FCALL                                          0  $2      
          5        SEND_VAR                                                     $2
          6        DO_ICALL                                                     
          7      > RETURN                                                       1

Function parselog:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 70
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 70
Branch analysis from position: 9
2 jumps found. (Code = 47) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 34
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 30
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 30
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 41
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 48
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
Branch analysis from position: 48
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 62
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
Branch analysis from position: 62
2 jumps found. (Code = 43) Position 1 = 64, Position 2 = 67
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 17
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 70
filename:       /in/7eGFF
function name:  parseLog
number of ops:  73
compiled vars:  !0 = $log, !1 = $lines, !2 = $history, !3 = $line, !4 = $key, !5 = $commit
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        INIT_FCALL                                                   'explode'
          2        SEND_VAL                                                     '%0A'
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                             $6      
          5        ASSIGN                                                       !1, $6
    5     6        ASSIGN                                                       !2, <array>
    6     7      > FE_RESET_R                                           $9      !1, ->70
          8    > > FE_FETCH_R                                           ~10     $9, !3, ->70
          9    >   ASSIGN                                                       !4, ~10
    7    10        FRAMELESS_ICALL_2                strpos              ~12     !3, 'commit'
         11        IS_IDENTICAL                                         ~13     ~12, 0
         12      > JMPNZ_EX                                             ~13     ~13, ->17
         13    >   ADD                                                  ~14     !4, 1
         14        COUNT                                                ~15     !1
         15        IS_EQUAL                                             ~16     ~14, ~15
         16        BOOL                                                 ~13     ~16
         17    > > JMPZ                                                         ~13, ->34
    8    18    >   ISSET_ISEMPTY_CV                                     ~17     !5
         19        BOOL_NOT                                             ~18     ~17
         20      > JMPZ                                                         ~18, ->30
    9    21    >   FETCH_DIM_R                                          ~20     !5, 'message'
         22        FRAMELESS_ICALL_2                substr              ~21     ~20, 4
         23        ASSIGN_DIM                                                   !5, 'message'
         24        OP_DATA                                                      ~21
   10    25        INIT_FCALL                                                   'array_push'
         26        SEND_REF                                                     !2
         27        SEND_VAR                                                     !5
         28        DO_ICALL                                                     
   11    29        UNSET_CV                                                     !5
   13    30    >   FRAMELESS_ICALL_2                substr              ~24     !3, 7
         31        ASSIGN_DIM                                                   !5, 'hash'
         32        OP_DATA                                                      ~24
    7    33      > JMP                                                          ->69
   14    34    >   FRAMELESS_ICALL_2                strpos              ~25     !3, 'Author'
         35        IS_IDENTICAL                                                 ~25, 0
         36      > JMPZ                                                         ~26, ->41
   15    37    >   FRAMELESS_ICALL_2                substr              ~28     !3, 8
         38        ASSIGN_DIM                                                   !5, 'author'
         39        OP_DATA                                                      ~28
   14    40      > JMP                                                          ->69
   16    41    >   FRAMELESS_ICALL_2                strpos              ~29     !3, 'Date'
         42        IS_IDENTICAL                                                 ~29, 0
         43      > JMPZ                                                         ~30, ->48
   17    44    >   FRAMELESS_ICALL_2                substr              ~32     !3, 8
         45        ASSIGN_DIM                                                   !5, 'date'
         46        OP_DATA                                                      ~32
   16    47      > JMP                                                          ->69
   18    48    >   FRAMELESS_ICALL_2                strpos              ~33     !3, 'Merge'
         49        IS_IDENTICAL                                                 ~33, 0
         50      > JMPZ                                                         ~34, ->62
   19    51    >   FRAMELESS_ICALL_2                substr              ~36     !3, 7
         52        ASSIGN_DIM                                                   !5, 'merge'
         53        OP_DATA                                                      ~36
   20    54        INIT_FCALL                                                   'explode'
         55        SEND_VAL                                                     '+'
         56        FETCH_DIM_R                                          ~38     !5, 'merge'
         57        SEND_VAL                                                     ~38
         58        DO_ICALL                                             $39     
         59        ASSIGN_DIM                                                   !5, 'merge'
         60        OP_DATA                                                      $39
   18    61      > JMP                                                          ->69
   22    62    >   ISSET_ISEMPTY_DIM_OBJ                             0          !5, 'message'
         63      > JMPZ                                                         ~40, ->67
   23    64    >   ASSIGN_DIM_OP                    .=               8          !5, 'message'
         65        OP_DATA                                                      !3
   22    66      > JMP                                                          ->69
   25    67    >   ASSIGN_DIM                                                   !5, 'message'
         68        OP_DATA                                                      !3
    6    69    > > JMP                                                          ->8
         70    >   FE_FREE                                                      $9
   29    71      > RETURN                                                       !2
   30    72*     > RETURN                                                       null

End of function parselog

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
157.75 ms | 2316 KiB | 17 Q