3v4l.org

run code in 500+ PHP versions simultaneously
<?php $masks = ['1224*', '543*', '321*', '12245*', '5*', '122488*']; sort($masks); $needle = rtrim(array_shift($masks), '*'); $keep[] = $needle; foreach ($masks as $mask) { if (strpos($mask, $needle) !== 0) { $needle = rtrim($mask, '*'); $keep[] = $needle; } } // now $keep only contains: ['1224', '321', '5'] $numbers = ['122456789', '123456788', '321876543234567', '55555555555555555', '987654321']; var_export( preg_grep('~^(?:' . implode('|', $keep) . ')~', $numbers) );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 27
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 27
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 26
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 26
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/uLOKf
function name:  (null)
number of ops:  40
compiled vars:  !0 = $masks, !1 = $needle, !2 = $keep, !3 = $mask, !4 = $numbers
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        INIT_FCALL                                                   'sort'
          2        SEND_REF                                                     !0
          3        DO_ICALL                                                     
    5     4        INIT_FCALL                                                   'rtrim'
          5        INIT_FCALL                                                   'array_shift'
          6        SEND_REF                                                     !0
          7        DO_ICALL                                             $7      
          8        SEND_VAR                                                     $7
          9        SEND_VAL                                                     '%2A'
         10        DO_ICALL                                             $8      
         11        ASSIGN                                                       !1, $8
    6    12        ASSIGN_DIM                                                   !2
         13        OP_DATA                                                      !1
    7    14      > FE_RESET_R                                           $11     !0, ->27
         15    > > FE_FETCH_R                                                   $11, !3, ->27
    8    16    >   FRAMELESS_ICALL_2                strpos              ~12     !3, !1
         17        IS_NOT_IDENTICAL                                             ~12, 0
         18      > JMPZ                                                         ~13, ->26
    9    19    >   INIT_FCALL                                                   'rtrim'
         20        SEND_VAR                                                     !3
         21        SEND_VAL                                                     '%2A'
         22        DO_ICALL                                             $14     
         23        ASSIGN                                                       !1, $14
   10    24        ASSIGN_DIM                                                   !2
         25        OP_DATA                                                      !1
    7    26    > > JMP                                                          ->15
         27    >   FE_FREE                                                      $11
   15    28        ASSIGN                                                       !4, <array>
   17    29        INIT_FCALL                                                   'var_export'
   18    30        INIT_FCALL                                                   'preg_grep'
         31        FRAMELESS_ICALL_2                implode             ~18     '%7C', !2
         32        CONCAT                                               ~19     '%7E%5E%28%3F%3A', ~18
         33        CONCAT                                               ~20     ~19, '%29%7E'
         34        SEND_VAL                                                     ~20
         35        SEND_VAR                                                     !4
         36        DO_ICALL                                             $21     
         37        SEND_VAR                                                     $21
   17    38        DO_ICALL                                                     
   19    39      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
217.93 ms | 2001 KiB | 18 Q