3v4l.org

run code in 500+ PHP versions simultaneously
<?php $currencies = [ 'USD', 'BTC', 'DASH', 'LTC', 'SC', 'STEEM', 'WAVES', 'SNGLS', '1ST', 'BQX', 'ETH', 'PTOY', 'XAUR', ]; $input = [ "BTCUSD", "DASHBTC", "DOGEUSD", "LTCBTC", "LTCUSD", "SCBTC", "STEEMBTC", "WAVESBTC", "SNGLSBTC", "1STBTC", "DASHUSD", "BQXETH", "PTOYETH", "XAURETH", "BTCUSDT", ]; $output=[]; function filterCurrency($doubleCurrency, $key){ global $output; global $currencies; foreach($currencies as $currency){ $pattern = '/^'.$currency. '/'; preg_match($pattern, $doubleCurrency, $matches); if(array_key_exists(0, $matches)){ $output[]=$matches[0]; } } } array_walk_recursive($input, 'filterCurrency'); var_dump($output);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mhjBD
function name:  (null)
number of ops:  11
compiled vars:  !0 = $currencies, !1 = $input, !2 = $output
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   19     1        ASSIGN                                                       !1, <array>
   37     2        ASSIGN                                                       !2, <array>
   50     3        INIT_FCALL                                                   'array_walk_recursive'
          4        SEND_REF                                                     !1
          5        SEND_VAL                                                     'filterCurrency'
          6        DO_ICALL                                                     
   51     7        INIT_FCALL                                                   'var_dump'
          8        SEND_VAR                                                     !2
          9        DO_ICALL                                                     
         10      > RETURN                                                       1

Function filtercurrency:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 20
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 20
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 19
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/mhjBD
function name:  filterCurrency
number of ops:  22
compiled vars:  !0 = $doubleCurrency, !1 = $key, !2 = $output, !3 = $currencies, !4 = $currency, !5 = $pattern, !6 = $matches
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   39     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   40     2        BIND_GLOBAL                                                  !2, 'output'
   41     3        BIND_GLOBAL                                                  !3, 'currencies'
   42     4      > FE_RESET_R                                           $7      !3, ->20
          5    > > FE_FETCH_R                                                   $7, !4, ->20
   43     6    >   CONCAT                                               ~8      '%2F%5E', !4
          7        CONCAT                                               ~9      ~8, '%2F'
          8        ASSIGN                                                       !5, ~9
   44     9        INIT_FCALL                                                   'preg_match'
         10        SEND_VAR                                                     !5
         11        SEND_VAR                                                     !0
         12        SEND_REF                                                     !6
         13        DO_ICALL                                                     
   45    14        ARRAY_KEY_EXISTS                                             0, !6
         15      > JMPZ                                                         ~12, ->19
   46    16    >   FETCH_DIM_R                                          ~14     !6, 0
         17        ASSIGN_DIM                                                   !2
         18        OP_DATA                                                      ~14
   42    19    > > JMP                                                          ->5
         20    >   FE_FREE                                                      $7
   49    21      > RETURN                                                       null

End of function filtercurrency

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.95 ms | 2299 KiB | 16 Q