3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sc = 'hello 8491241 some text 6254841 some text 568241 414844:412'; preg_match_all('/([0-9]{5,10})(:[0-9]{1,5})?/', $sc, $matches, PREG_SET_ORDER); $all_matches = array_reduce($matches, function (array $all, array $match) { $all[] = ['batch' => $match[1], 'type' => '1']; if (isset($match[2])) { $all[] = ['batch' => $match[0], 'type' => '2']; } return $all; }, []); print_r($all_matches);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VhM7G
function name:  (null)
number of ops:  18
compiled vars:  !0 = $sc, !1 = $matches, !2 = $all_matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'hello+8491241+some+text+6254841+some+text+568241+414844%3A412'
    4     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%2F%28%5B0-9%5D%7B5%2C10%7D%29%28%3A%5B0-9%5D%7B1%2C5%7D%29%3F%2F'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        SEND_VAL                                                 2
          6        DO_ICALL                                                 
    6     7        INIT_FCALL                                               'array_reduce'
          8        SEND_VAR                                                 !1
          9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FVhM7G%3A6%240'
   12    10        SEND_VAL                                                 ~5
         11        SEND_VAL                                                 <array>
         12        DO_ICALL                                         $6      
    6    13        ASSIGN                                                   !2, $6
   14    14        INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FVhM7G%3A6%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/VhM7G
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $all, !1 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        FETCH_DIM_R                                      ~3      !1, 1
          3        INIT_ARRAY                                       ~4      ~3, 'batch'
          4        ADD_ARRAY_ELEMENT                                ~4      '1', 'type'
          5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  ~4
    8     7        ISSET_ISEMPTY_DIM_OBJ                         0          !1, 2
          8      > JMPZ                                                     ~5, ->14
    9     9    >   FETCH_DIM_R                                      ~7      !1, 0
         10        INIT_ARRAY                                       ~8      ~7, 'batch'
         11        ADD_ARRAY_ELEMENT                                ~8      '2', 'type'
         12        ASSIGN_DIM                                               !0
         13        OP_DATA                                                  ~8
   11    14    > > RETURN                                                   !0
   12    15*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FVhM7G%3A6%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.34 ms | 1396 KiB | 19 Q