3v4l.org

run code in 300+ PHP versions simultaneously
<?php $commentString = "His phone is not functional because the camera does not appear/work and he needs it to be usable for Cerity. It also freezes up. He's had his last phone for 3 years, it's time for an upgrade. Thank you!"; $comments = array(); $labels = array( 'Comment Type:' => 'type', 'Comment Body:' => 'body', 'Comment By:' => 'by', 'Comment Date:' => 'date' ); $commentParts = explode('Comment Type:', $commentsString); foreach ($commentParts as $commentPart) { $comment = array(); $commentLines = explode("\n", $commentPart); array_walk($commentLines, create_function('&$val', '$val = trim($val);')); $currentLabel = 'unknown'; foreach ($commentLines as $line) { if (empty($line)) continue; if (empty($comment['type'])) { $comment['type'] = $line; continue; } if (substr($line, 0, 5) == 'Body:') { $line = substr($line, 5); $currentLabel = 'body'; } if (in_array($line, array_keys($labels))) { $currentLabel = $labels[$line]; $comment[$currentLabel] = ''; } else { if (empty($comment[$currentLabel])) $comment[$currentLabel] = ''; $comment[$currentLabel] .= $line . ' '; } } if (!empty($comment)) $comments[] = $comment; } var_dump($comments);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 76
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 76
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 69
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 69
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 30
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 35
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 48
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 61
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 61
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 65
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 65
Branch analysis from position: 48
Branch analysis from position: 69
2 jumps found. (Code = 43) Position 1 = 73, Position 2 = 75
Branch analysis from position: 73
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 75
Branch analysis from position: 69
Branch analysis from position: 76
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 76
filename:       /in/4jJah
function name:  (null)
number of ops:  81
compiled vars:  !0 = $commentString, !1 = $comments, !2 = $labels, !3 = $commentParts, !4 = $commentsString, !5 = $commentPart, !6 = $comment, !7 = $commentLines, !8 = $currentLabel, !9 = $line
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'His+phone+is+not+functional+because+the+camera+does+not+appear%2Fwork+and+he%0A++++++++++++++++++++needs+it+to+be+usable+for+Cerity.+It+also+freezes+up.+He%27s+had+his+last+phone+for+3+years%2C+it%27s+time%0A++++++++++++++++++++for+an+upgrade.+Thank+you%21'
    5     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, <array>
   13     3        INIT_FCALL                                               'explode'
          4        SEND_VAL                                                 'Comment+Type%3A'
          5        SEND_VAR                                                 !4
          6        DO_ICALL                                         $13     
          7        ASSIGN                                                   !3, $13
   15     8      > FE_RESET_R                                       $15     !3, ->76
          9    > > FE_FETCH_R                                               $15, !5, ->76
   16    10    >   ASSIGN                                                   !6, <array>
   17    11        INIT_FCALL                                               'explode'
         12        SEND_VAL                                                 '%0A'
         13        SEND_VAR                                                 !5
         14        DO_ICALL                                         $17     
         15        ASSIGN                                                   !7, $17
   18    16        INIT_FCALL                                               'array_walk'
         17        SEND_REF                                                 !7
         18        INIT_FCALL_BY_NAME                                       'create_function'
         19        SEND_VAL_EX                                              '%26%24val'
         20        SEND_VAL_EX                                              '%24val+%3D+trim%28%24val%29%3B'
         21        DO_FCALL                                      0  $19     
         22        SEND_VAR                                                 $19
         23        DO_ICALL                                                 
   19    24        ASSIGN                                                   !8, 'unknown'
   21    25      > FE_RESET_R                                       $22     !7, ->69
         26    > > FE_FETCH_R                                               $22, !9, ->69
   22    27    >   ISSET_ISEMPTY_CV                                         !9
         28      > JMPZ                                                     ~23, ->30
         29    > > JMP                                                      ->26
   24    30    >   ISSET_ISEMPTY_DIM_OBJ                         1          !6, 'type'
         31      > JMPZ                                                     ~24, ->35
   25    32    >   ASSIGN_DIM                                               !6, 'type'
         33        OP_DATA                                                  !9
   26    34      > JMP                                                      ->26
   29    35    >   INIT_FCALL                                               'substr'
         36        SEND_VAR                                                 !9
         37        SEND_VAL                                                 0
         38        SEND_VAL                                                 5
         39        DO_ICALL                                         $26     
         40        IS_EQUAL                                                 $26, 'Body%3A'
         41      > JMPZ                                                     ~27, ->48
   30    42    >   INIT_FCALL                                               'substr'
         43        SEND_VAR                                                 !9
         44        SEND_VAL                                                 5
         45        DO_ICALL                                         $28     
         46        ASSIGN                                                   !9, $28
   31    47        ASSIGN                                                   !8, 'body'
   34    48    >   INIT_FCALL                                               'in_array'
         49        SEND_VAR                                                 !9
         50        INIT_FCALL                                               'array_keys'
         51        SEND_VAR                                                 !2
         52        DO_ICALL                                         $31     
         53        SEND_VAR                                                 $31
         54        DO_ICALL                                         $32     
         55      > JMPZ                                                     $32, ->61
   35    56    >   FETCH_DIM_R                                      ~33     !2, !9
         57        ASSIGN                                                   !8, ~33
   36    58        ASSIGN_DIM                                               !6, !8
         59        OP_DATA                                                  ''
         60      > JMP                                                      ->68
   38    61    >   ISSET_ISEMPTY_DIM_OBJ                         1          !6, !8
         62      > JMPZ                                                     ~36, ->65
         63    >   ASSIGN_DIM                                               !6, !8
         64        OP_DATA                                                  ''
   39    65    >   CONCAT                                           ~39     !9, '+'
         66        ASSIGN_DIM_OP                .=               8          !6, !8
         67        OP_DATA                                                  ~39
   21    68    > > JMP                                                      ->26
         69    >   FE_FREE                                                  $22
   43    70        ISSET_ISEMPTY_CV                                 ~40     !6
         71        BOOL_NOT                                         ~41     ~40
         72      > JMPZ                                                     ~41, ->75
         73    >   ASSIGN_DIM                                               !1
         74        OP_DATA                                                  !6
   15    75    > > JMP                                                      ->9
         76    >   FE_FREE                                                  $15
   45    77        INIT_FCALL                                               'var_dump'
         78        SEND_VAR                                                 !1
         79        DO_ICALL                                                 
         80      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.13 ms | 1404 KiB | 25 Q