3v4l.org

run code in 300+ PHP versions simultaneously
<?php $commentsString = "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); if(strpos($commentsString, 'Comment Type:') !== 0){ $comments[] = array( 'type'=>'Text Only', 'body'=>$commentsString, 'by'=>'', 'date'=>'' ); } else { 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 = 43) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 90
Branch analysis from position: 90
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 89
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 89
Branch analysis from position: 23
2 jumps found. (Code = 77) Position 1 = 39, Position 2 = 82
Branch analysis from position: 39
2 jumps found. (Code = 78) Position 1 = 40, Position 2 = 82
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 43
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 48
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 48
2 jumps found. (Code = 43) Position 1 = 55, Position 2 = 61
Branch analysis from position: 55
2 jumps found. (Code = 43) Position 1 = 69, Position 2 = 74
Branch analysis from position: 69
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 74
2 jumps found. (Code = 43) Position 1 = 76, Position 2 = 78
Branch analysis from position: 76
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 78
Branch analysis from position: 61
Branch analysis from position: 82
2 jumps found. (Code = 43) Position 1 = 86, Position 2 = 88
Branch analysis from position: 86
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 88
Branch analysis from position: 82
Branch analysis from position: 89
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 89
filename:       /in/FME14
function name:  (null)
number of ops:  94
compiled vars:  !0 = $commentsString, !1 = $comments, !2 = $labels, !3 = $commentParts, !4 = $commentPart, !5 = $comment, !6 = $commentLines, !7 = $currentLabel, !8 = $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>
    7     2        ASSIGN                                                   !2, <array>
   14     3        INIT_FCALL                                               'explode'
          4        SEND_VAL                                                 'Comment+Type%3A'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $12     
          7        ASSIGN                                                   !3, $12
   15     8        INIT_FCALL                                               'strpos'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 'Comment+Type%3A'
         11        DO_ICALL                                         $14     
         12        IS_NOT_IDENTICAL                                         $14, 0
         13      > JMPZ                                                     ~15, ->21
   17    14    >   INIT_ARRAY                                       ~17     'Text+Only', 'type'
   18    15        ADD_ARRAY_ELEMENT                                ~17     !0, 'body'
   19    16        ADD_ARRAY_ELEMENT                                ~17     '', 'by'
   20    17        ADD_ARRAY_ELEMENT                                ~17     '', 'date'
   16    18        ASSIGN_DIM                                               !1
   20    19        OP_DATA                                                  ~17
         20      > JMP                                                      ->90
   26    21    > > FE_RESET_R                                       $18     !3, ->89
         22    > > FE_FETCH_R                                               $18, !4, ->89
   27    23    >   ASSIGN                                                   !5, <array>
   28    24        INIT_FCALL                                               'explode'
         25        SEND_VAL                                                 '%0A'
         26        SEND_VAR                                                 !4
         27        DO_ICALL                                         $20     
         28        ASSIGN                                                   !6, $20
   29    29        INIT_FCALL                                               'array_walk'
         30        SEND_REF                                                 !6
         31        INIT_FCALL_BY_NAME                                       'create_function'
         32        SEND_VAL_EX                                              '%26%24val'
         33        SEND_VAL_EX                                              '%24val+%3D+trim%28%24val%29%3B'
         34        DO_FCALL                                      0  $22     
         35        SEND_VAR                                                 $22
         36        DO_ICALL                                                 
   30    37        ASSIGN                                                   !7, 'unknown'
   32    38      > FE_RESET_R                                       $25     !6, ->82
         39    > > FE_FETCH_R                                               $25, !8, ->82
   33    40    >   ISSET_ISEMPTY_CV                                         !8
         41      > JMPZ                                                     ~26, ->43
         42    > > JMP                                                      ->39
   35    43    >   ISSET_ISEMPTY_DIM_OBJ                         1          !5, 'type'
         44      > JMPZ                                                     ~27, ->48
   36    45    >   ASSIGN_DIM                                               !5, 'type'
         46        OP_DATA                                                  !8
   37    47      > JMP                                                      ->39
   40    48    >   INIT_FCALL                                               'substr'
         49        SEND_VAR                                                 !8
         50        SEND_VAL                                                 0
         51        SEND_VAL                                                 5
         52        DO_ICALL                                         $29     
         53        IS_EQUAL                                                 $29, 'Body%3A'
         54      > JMPZ                                                     ~30, ->61
   41    55    >   INIT_FCALL                                               'substr'
         56        SEND_VAR                                                 !8
         57        SEND_VAL                                                 5
         58        DO_ICALL                                         $31     
         59        ASSIGN                                                   !8, $31
   42    60        ASSIGN                                                   !7, 'body'
   45    61    >   INIT_FCALL                                               'in_array'
         62        SEND_VAR                                                 !8
         63        INIT_FCALL                                               'array_keys'
         64        SEND_VAR                                                 !2
         65        DO_ICALL                                         $34     
         66        SEND_VAR                                                 $34
         67        DO_ICALL                                         $35     
         68      > JMPZ                                                     $35, ->74
   46    69    >   FETCH_DIM_R                                      ~36     !2, !8
         70        ASSIGN                                                   !7, ~36
   47    71        ASSIGN_DIM                                               !5, !7
         72        OP_DATA                                                  ''
         73      > JMP                                                      ->81
   49    74    >   ISSET_ISEMPTY_DIM_OBJ                         1          !5, !7
         75      > JMPZ                                                     ~39, ->78
         76    >   ASSIGN_DIM                                               !5, !7
         77        OP_DATA                                                  ''
   50    78    >   CONCAT                                           ~42     !8, '+'
         79        ASSIGN_DIM_OP                .=               8          !5, !7
         80        OP_DATA                                                  ~42
   32    81    > > JMP                                                      ->39
         82    >   FE_FREE                                                  $25
   54    83        ISSET_ISEMPTY_CV                                 ~43     !5
         84        BOOL_NOT                                         ~44     ~43
         85      > JMPZ                                                     ~44, ->88
         86    >   ASSIGN_DIM                                               !1
         87        OP_DATA                                                  !5
   26    88    > > JMP                                                      ->22
         89    >   FE_FREE                                                  $18
   57    90    >   INIT_FCALL                                               'var_dump'
         91        SEND_VAR                                                 !1
         92        DO_ICALL                                                 
         93      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.96 ms | 1404 KiB | 27 Q