3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = "/mango|apple|banana/"; $text = "i like banana and apple alot"; echo preg_replace_callback($pattern, function($matches){ $str = $matches[0]; $len = strlen($str); $stars = str_repeat('*', $len-2); return $str[0].$stars.$str[$len-1]; }, $text);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pKFZg
function name:  (null)
number of ops:  10
compiled vars:  !0 = $pattern, !1 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%2Fmango%7Capple%7Cbanana%2F'
    3     1        ASSIGN                                                   !1, 'i+like+banana+and+apple+alot'
    4     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FpKFZg%3A4%240'
    9     5        SEND_VAL                                                 ~4
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $5      
          8        ECHO                                                     $5
          9      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FpKFZg%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pKFZg
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $matches, !1 = $str, !2 = $len, !3 = $stars
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        FETCH_DIM_R                                      ~4      !0, 0
          2        ASSIGN                                                   !1, ~4
    6     3        STRLEN                                           ~6      !1
          4        ASSIGN                                                   !2, ~6
    7     5        INIT_FCALL                                               'str_repeat'
          6        SEND_VAL                                                 '%2A'
          7        SUB                                              ~8      !2, 2
          8        SEND_VAL                                                 ~8
          9        DO_ICALL                                         $9      
         10        ASSIGN                                                   !3, $9
    8    11        FETCH_DIM_R                                      ~11     !1, 0
         12        CONCAT                                           ~12     ~11, !3
         13        SUB                                              ~13     !2, 1
         14        FETCH_DIM_R                                      ~14     !1, ~13
         15        CONCAT                                           ~15     ~12, ~14
         16      > RETURN                                                   ~15
    9    17*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FpKFZg%3A4%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.86 ms | 1388 KiB | 17 Q