3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = <<< END 2x egg 2 - carrot cabbage 1x potato END; $lines = explode("\n", $str); $ingredients = Array(); foreach($lines as $line) { $matches = Array(); if(!preg_match("/^(\d+).*?(\S+)$/", $line, $matches)) array_push($ingredients, Array(1, $line)); else array_push($ingredients, Array(intval($matches[1]), $matches[2])); } var_dump($ingredients);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 34
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 34
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 24
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/bdrnY
function name:  (null)
number of ops:  39
compiled vars:  !0 = $str, !1 = $lines, !2 = $ingredients, !3 = $line, !4 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '2x+egg%0A2+-+carrot%0Acabbage%0A1x+potato'
   10     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%0A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !1, $6
   11     6        ASSIGN                                                   !2, <array>
   12     7      > FE_RESET_R                                       $9      !1, ->34
          8    > > FE_FETCH_R                                               $9, !3, ->34
   13     9    >   ASSIGN                                                   !4, <array>
   14    10        INIT_FCALL                                               'preg_match'
         11        SEND_VAL                                                 '%2F%5E%28%5Cd%2B%29.%2A%3F%28%5CS%2B%29%24%2F'
         12        SEND_VAR                                                 !3
         13        SEND_REF                                                 !4
         14        DO_ICALL                                         $11     
         15        BOOL_NOT                                         ~12     $11
         16      > JMPZ                                                     ~12, ->24
   15    17    >   INIT_FCALL                                               'array_push'
         18        SEND_REF                                                 !2
         19        INIT_ARRAY                                       ~13     1
         20        ADD_ARRAY_ELEMENT                                ~13     !3
         21        SEND_VAL                                                 ~13
         22        DO_ICALL                                                 
         23      > JMP                                                      ->33
   17    24    >   INIT_FCALL                                               'array_push'
         25        SEND_REF                                                 !2
         26        FETCH_DIM_R                                      ~15     !4, 1
         27        CAST                                          4  ~16     ~15
         28        INIT_ARRAY                                       ~17     ~16
         29        FETCH_DIM_R                                      ~18     !4, 2
         30        ADD_ARRAY_ELEMENT                                ~17     ~18
         31        SEND_VAL                                                 ~17
         32        DO_ICALL                                                 
   12    33    > > JMP                                                      ->8
         34    >   FE_FREE                                                  $9
   20    35        INIT_FCALL                                               'var_dump'
         36        SEND_VAR                                                 !2
         37        DO_ICALL                                                 
         38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.95 ms | 1392 KiB | 21 Q