3v4l.org

run code in 300+ 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 = 97
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 97
Branch analysis from position: 9
2 jumps found. (Code = 47) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 43
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 36
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 96
Branch analysis from position: 96
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 36
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 56
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 96
Branch analysis from position: 96
Branch analysis from position: 56
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 69
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 96
Branch analysis from position: 96
Branch analysis from position: 69
2 jumps found. (Code = 43) Position 1 = 75, Position 2 = 89
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 96
Branch analysis from position: 96
Branch analysis from position: 89
2 jumps found. (Code = 43) Position 1 = 91, Position 2 = 94
Branch analysis from position: 91
1 jumps found. (Code = 42) Position 1 = 96
Branch analysis from position: 96
Branch analysis from position: 94
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 20
Branch analysis from position: 97
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 97
filename:       /in/7eGFF
function name:  parseLog
number of ops:  100
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, ->97
          8    > > FE_FETCH_R                                       ~10     $9, !3, ->97
          9    >   ASSIGN                                                   !4, ~10
    7    10        INIT_FCALL                                               'strpos'
         11        SEND_VAR                                                 !3
         12        SEND_VAL                                                 'commit'
         13        DO_ICALL                                         $12     
         14        IS_IDENTICAL                                     ~13     $12, 0
         15      > JMPNZ_EX                                         ~13     ~13, ->20
         16    >   ADD                                              ~14     !4, 1
         17        COUNT                                            ~15     !1
         18        IS_EQUAL                                         ~16     ~14, ~15
         19        BOOL                                             ~13     ~16
         20    > > JMPZ                                                     ~13, ->43
    8    21    >   ISSET_ISEMPTY_CV                                 ~17     !5
         22        BOOL_NOT                                         ~18     ~17
         23      > JMPZ                                                     ~18, ->36
    9    24    >   INIT_FCALL                                               'substr'
         25        FETCH_DIM_R                                      ~20     !5, 'message'
         26        SEND_VAL                                                 ~20
         27        SEND_VAL                                                 4
         28        DO_ICALL                                         $21     
         29        ASSIGN_DIM                                               !5, 'message'
         30        OP_DATA                                                  $21
   10    31        INIT_FCALL                                               'array_push'
         32        SEND_REF                                                 !2
         33        SEND_VAR                                                 !5
         34        DO_ICALL                                                 
   11    35        UNSET_CV                                                 !5
   13    36    >   INIT_FCALL                                               'substr'
         37        SEND_VAR                                                 !3
         38        SEND_VAL                                                 7
         39        DO_ICALL                                         $24     
         40        ASSIGN_DIM                                               !5, 'hash'
         41        OP_DATA                                                  $24
    7    42      > JMP                                                      ->96
   14    43    >   INIT_FCALL                                               'strpos'
         44        SEND_VAR                                                 !3
         45        SEND_VAL                                                 'Author'
         46        DO_ICALL                                         $25     
         47        IS_IDENTICAL                                             $25, 0
         48      > JMPZ                                                     ~26, ->56
   15    49    >   INIT_FCALL                                               'substr'
         50        SEND_VAR                                                 !3
         51        SEND_VAL                                                 8
         52        DO_ICALL                                         $28     
         53        ASSIGN_DIM                                               !5, 'author'
         54        OP_DATA                                                  $28
   14    55      > JMP                                                      ->96
   16    56    >   INIT_FCALL                                               'strpos'
         57        SEND_VAR                                                 !3
         58        SEND_VAL                                                 'Date'
         59        DO_ICALL                                         $29     
         60        IS_IDENTICAL                                             $29, 0
         61      > JMPZ                                                     ~30, ->69
   17    62    >   INIT_FCALL                                               'substr'
         63        SEND_VAR                                                 !3
         64        SEND_VAL                                                 8
         65        DO_ICALL                                         $32     
         66        ASSIGN_DIM                                               !5, 'date'
         67        OP_DATA                                                  $32
   16    68      > JMP                                                      ->96
   18    69    >   INIT_FCALL                                               'strpos'
         70        SEND_VAR                                                 !3
         71        SEND_VAL                                                 'Merge'
         72        DO_ICALL                                         $33     
         73        IS_IDENTICAL                                             $33, 0
         74      > JMPZ                                                     ~34, ->89
   19    75    >   INIT_FCALL                                               'substr'
         76        SEND_VAR                                                 !3
         77        SEND_VAL                                                 7
         78        DO_ICALL                                         $36     
         79        ASSIGN_DIM                                               !5, 'merge'
         80        OP_DATA                                                  $36
   20    81        INIT_FCALL                                               'explode'
         82        SEND_VAL                                                 '+'
         83        FETCH_DIM_R                                      ~38     !5, 'merge'
         84        SEND_VAL                                                 ~38
         85        DO_ICALL                                         $39     
         86        ASSIGN_DIM                                               !5, 'merge'
         87        OP_DATA                                                  $39
   18    88      > JMP                                                      ->96
   22    89    >   ISSET_ISEMPTY_DIM_OBJ                         0          !5, 'message'
         90      > JMPZ                                                     ~40, ->94
   23    91    >   ASSIGN_DIM_OP                .=               8          !5, 'message'
         92        OP_DATA                                                  !3
   22    93      > JMP                                                      ->96
   25    94    >   ASSIGN_DIM                                               !5, 'message'
         95        OP_DATA                                                  !3
    6    96    > > JMP                                                      ->8
         97    >   FE_FREE                                                  $9
   29    98      > RETURN                                                   !2
   30    99*     > RETURN                                                   null

End of function parselog

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.66 ms | 1017 KiB | 19 Q