3v4l.org

run code in 500+ PHP versions simultaneously
<?php //$s = "--included-- in package price: 5 % vat aed 10.00 destination fee per night 2 % municipality fee 3.5 % packaging fee 10 % warranty service charge breakfast"; $s = "--included-- in product price: breakfast --excluded--: 5 % vat aed 10.00 destination fee per night 2 % municipality fee 3.5 % packaging fee 10 % warranty service charge"; $results = []; if (preg_match_all('~(--(?:(?:not )?in|ex)cluded--)(?:\s+([a-zA-Z ]+))?:+\s*((?:(?!--(?:(?:not )?in|ex)cluded--).)*)~su', $s, $m, PREG_SET_ORDER, 0)) { foreach ($m as $v) { $lastline=array_pop($v); // Remove last item //print_r($details); if (preg_match_all('~(?:(\b(?:usd|aed|mad|usd)\b|\B€|\bus\$)\s*)?\d+(?:\.\d+)?(?:(?!(?1))\D)*~u', $lastline, $details)) { $results[] = array_merge($v, $details[0]); } else { $results[] = $v; } } //[3] => 5 % vat aed [4] => 10.00 destination fee per night //[3] => 5 % vat [4] => aed 10.00 destination fee per night } print_r($results);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 34
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 33
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 33
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 30
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
Branch analysis from position: 34
filename:       /in/3PJ9J
function name:  (null)
number of ops:  38
compiled vars:  !0 = $s, !1 = $results, !2 = $m, !3 = $v, !4 = $lastline, !5 = $details
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                       !0, '--included--+in+product+price%3A+breakfast+--excluded--%3A+5+%25+vat+aed+10.00+destination+fee+per+night+2+%25+municipality+fee+3.5+%25+packaging+fee+10+%25+warranty+service+charge'
    5     1        ASSIGN                                                       !1, <array>
    6     2        INIT_FCALL                                                   'preg_match_all'
          3        SEND_VAL                                                     '%7E%28--%28%3F%3A%28%3F%3Anot+%29%3Fin%7Cex%29cluded--%29%28%3F%3A%5Cs%2B%28%5Ba-zA-Z+%5D%2B%29%29%3F%3A%2B%5Cs%2A%28%28%3F%3A%28%3F%21--%28%3F%3A%28%3F%3Anot+%29%3Fin%7Cex%29cluded--%29.%29%2A%29%7Esu'
          4        SEND_VAR                                                     !0
          5        SEND_REF                                                     !2
          6        SEND_VAL                                                     2
          7        SEND_VAL                                                     0
          8        DO_ICALL                                             $8      
          9      > JMPZ                                                         $8, ->34
    7    10    > > FE_RESET_R                                           $9      !2, ->33
         11    > > FE_FETCH_R                                                   $9, !3, ->33
    8    12    >   INIT_FCALL                                                   'array_pop'
         13        SEND_REF                                                     !3
         14        DO_ICALL                                             $10     
         15        ASSIGN                                                       !4, $10
    9    16        INIT_FCALL                                                   'preg_match_all'
         17        SEND_VAL                                                     '%7E%28%3F%3A%28%5Cb%28%3F%3Ausd%7Caed%7Cmad%7Cusd%29%5Cb%7C%5CB%E2%82%AC%7C%5Cbus%5C%24%29%5Cs%2A%29%3F%5Cd%2B%28%3F%3A%5C.%5Cd%2B%29%3F%28%3F%3A%28%3F%21%28%3F1%29%29%5CD%29%2A%7Eu'
         18        SEND_VAR                                                     !4
         19        SEND_REF                                                     !5
         20        DO_ICALL                                             $12     
         21      > JMPZ                                                         $12, ->30
   10    22    >   INIT_FCALL                                                   'array_merge'
         23        SEND_VAR                                                     !3
         24        FETCH_DIM_R                                          ~14     !5, 0
         25        SEND_VAL                                                     ~14
         26        DO_ICALL                                             $15     
         27        ASSIGN_DIM                                                   !1
         28        OP_DATA                                                      $15
    9    29      > JMP                                                          ->32
   12    30    >   ASSIGN_DIM                                                   !1
         31        OP_DATA                                                      !3
    7    32    > > JMP                                                          ->11
         33    >   FE_FREE                                                      $9
   18    34    >   INIT_FCALL                                                   'print_r'
         35        SEND_VAR                                                     !1
         36        DO_ICALL                                                     
         37      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.84 ms | 2272 KiB | 17 Q