3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = " /\[ (?:block:(?<block>piechart)) (?: (?:\s+value:(?<value>[0-9]+)) | (?:\s+stroke:(?<stroke>[0-9]+)) | (?:\s+angle:(?<angle>[0-9]+)) | (?:\s+colorset:(?<colorset>reds|yellows|blues)) )* \]/xumi"; $subject = "here is a block to be replaced [block:piechart value:25 angle:0] [block] and another one [block:piechart colorset:reds value:20]"; preg_replace_callback($pattern, 'callbackFunction', $subject, -1, $count, PREG_UNMATCHED_AS_NULL); function callbackFunction($matches) { var_dump(array_filter($matches, function ($v) { return !is_null($v); })); // process matched values, return some replacement... $replacement = "..."; return $replacement; };
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/svKg9
function name:  (null)
number of ops:  11
compiled vars:  !0 = $pattern, !1 = $subject, !2 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%0A%2F%5C%5B%0A++++%28%3F%3Ablock%3A%28%3F%3Cblock%3Epiechart%29%29%0A++++%28%3F%3A%0A++++++++%28%3F%3A%5Cs%2Bvalue%3A%28%3F%3Cvalue%3E%5B0-9%5D%2B%29%29+%7C%0A++++++++%28%3F%3A%5Cs%2Bstroke%3A%28%3F%3Cstroke%3E%5B0-9%5D%2B%29%29+%7C%0A++++++++%28%3F%3A%5Cs%2Bangle%3A%28%3F%3Cangle%3E%5B0-9%5D%2B%29%29+%7C%0A++++++++%28%3F%3A%5Cs%2Bcolorset%3A%28%3F%3Ccolorset%3Ereds%7Cyellows%7Cblues%29%29%0A++++%29%2A%0A%5C%5D%2Fxumi'
   13     1        ASSIGN                                                   !1, 'here+is+a+block+to+be+replaced+%5Bblock%3Apiechart+value%3A25+++angle%3A0%5D++%5Bblock%5D+and+another+one+%5Bblock%3Apiechart+colorset%3Areds+value%3A20%5D'
   14     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'callbackFunction'
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 -1
          7        SEND_REF                                                 !2
          8        SEND_VAL                                                 512
          9        DO_ICALL                                                 
   24    10      > RETURN                                                   1

Function callbackfunction:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/svKg9
function name:  callbackFunction
number of ops:  12
compiled vars:  !0 = $matches, !1 = $replacement
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'array_filter'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                         $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                                 
   21     9        ASSIGN                                                   !1, '...'
   23    10      > RETURN                                                   !1
   24    11*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/svKg9
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        TYPE_CHECK                                    2  ~1      !0
          2        BOOL_NOT                                         ~2      ~1
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of Dynamic Function 0

End of function callbackfunction

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.97 ms | 1007 KiB | 16 Q