3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = [ "$20,000 AUD", "$20,000", "20,000 AUD", "$", "20,000", "AUD" ]; $re = '/(?P<symbol>[$¥£€₹])(?P<amount>\d{1,10}(?:[.,]\d{1,10})?)(?:\h+(?P<currency>AUD|USD|GBP|EURO?S?)\b)?\b|(?P<amount>\d{1,10}(?:[.,]\d{1,10})?)\h+(?P<currency>AUD|USD|GBP|EURO?S?)\b/J'; foreach ($strings as $s) { $m = preg_match($re, $s, $matches); if ($m) { $matches = array_filter($matches, "is_string", ARRAY_FILTER_USE_KEY); print_r($matches); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/npgqH
function name:  (null)
number of ops:  23
compiled vars:  !0 = $strings, !1 = $re, !2 = $s, !3 = $m, !4 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, '%2F%28%3FP%3Csymbol%3E%5B%24%C2%A5%C2%A3%E2%82%AC%E2%82%B9%5D%29%28%3FP%3Camount%3E%5Cd%7B1%2C10%7D%28%3F%3A%5B.%2C%5D%5Cd%7B1%2C10%7D%29%3F%29%28%3F%3A%5Ch%2B%28%3FP%3Ccurrency%3EAUD%7CUSD%7CGBP%7CEURO%3FS%3F%29%5Cb%29%3F%5Cb%7C%28%3FP%3Camount%3E%5Cd%7B1%2C10%7D%28%3F%3A%5B.%2C%5D%5Cd%7B1%2C10%7D%29%3F%29%5Ch%2B%28%3FP%3Ccurrency%3EAUD%7CUSD%7CGBP%7CEURO%3FS%3F%29%5Cb%2FJ'
   12     2      > FE_RESET_R                                       $7      !0, ->21
          3    > > FE_FETCH_R                                               $7, !2, ->21
   13     4    >   INIT_FCALL                                               'preg_match'
          5        SEND_VAR                                                 !1
          6        SEND_VAR                                                 !2
          7        SEND_REF                                                 !4
          8        DO_ICALL                                         $8      
          9        ASSIGN                                                   !3, $8
   14    10      > JMPZ                                                     !3, ->20
   15    11    >   INIT_FCALL                                               'array_filter'
         12        SEND_VAR                                                 !4
         13        SEND_VAL                                                 'is_string'
         14        SEND_VAL                                                 2
         15        DO_ICALL                                         $10     
         16        ASSIGN                                                   !4, $10
   16    17        INIT_FCALL                                               'print_r'
         18        SEND_VAR                                                 !4
         19        DO_ICALL                                                 
   12    20    > > JMP                                                      ->3
         21    >   FE_FREE                                                  $7
   18    22      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
292 ms | 1013 KiB | 16 Q