3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = [ "21-114512", "test12345abcd", "12test123456testing", "123456", "1234", "12345a67890" ]; function extract_numbers($string) { return preg_match_all('/(?<!\d)\d{5,6}(?!\d)/', $string, $match) ? $match[0] : []; } foreach ($strings as $string) { var_export(extract_numbers($string)); echo "\n---\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 11
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/NhDtr
function name:  (null)
number of ops:  13
compiled vars:  !0 = $strings, !1 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   15     1      > FE_RESET_R                                       $3      !0, ->11
          2    > > FE_FETCH_R                                               $3, !1, ->11
   16     3    >   INIT_FCALL                                               'var_export'
          4        INIT_FCALL                                               'extract_numbers'
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   17     9        ECHO                                                     '%0A---%0A'
   15    10      > JMP                                                      ->2
         11    >   FE_FREE                                                  $3
   18    12      > RETURN                                                   1

Function extract_numbers:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NhDtr
function name:  extract_numbers
number of ops:  13
compiled vars:  !0 = $string, !1 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   13     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%2F%28%3F%3C%21%5Cd%29%5Cd%7B5%2C6%7D%28%3F%21%5Cd%29%2F'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                         $2      
          6      > JMPZ                                                     $2, ->10
          7    >   FETCH_DIM_R                                      ~3      !1, 0
          8        QM_ASSIGN                                        ~4      ~3
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~4      <array>
         11    > > RETURN                                                   ~4
   14    12*     > RETURN                                                   null

End of function extract_numbers

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.09 ms | 1009 KiB | 16 Q