3v4l.org

run code in 300+ PHP versions simultaneously
<?php $original = 'some od or perhaps a #ph in this :rn:'; $abbreviation= array(); $abbreviation[0] = 'od'; $abbreviation[1] = 'rn'; $abbreviation[2] = 'ph'; $abbreviation[3] = 'real'; $translated= array(); $translated[0] ='odometer'; $translated[1] ='run'; $translated[2] ='pinhole'; $translated[3] ='fake'; function add_regex_finders($str){ return "/([\s:\#])" . $str . "([\s:])/i"; } $original_parsed = array_map('add_regex_finders',$abbreviation); echo preg_replace($original_parsed, array_map(function ($v) { return '$1' . $v . '$2'; }, $translated), $original);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TDGbJ
function name:  (null)
number of ops:  36
compiled vars:  !0 = $original, !1 = $abbreviation, !2 = $translated, !3 = $original_parsed
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'some+od+or+perhaps+a+%23ph+in+this+%3Arn%3A'
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN_DIM                                               !1, 0
          3        OP_DATA                                                  'od'
    6     4        ASSIGN_DIM                                               !1, 1
          5        OP_DATA                                                  'rn'
    7     6        ASSIGN_DIM                                               !1, 2
          7        OP_DATA                                                  'ph'
    8     8        ASSIGN_DIM                                               !1, 3
          9        OP_DATA                                                  'real'
    9    10        ASSIGN                                                   !2, <array>
   10    11        ASSIGN_DIM                                               !2, 0
         12        OP_DATA                                                  'odometer'
   11    13        ASSIGN_DIM                                               !2, 1
         14        OP_DATA                                                  'run'
   12    15        ASSIGN_DIM                                               !2, 2
         16        OP_DATA                                                  'pinhole'
   13    17        ASSIGN_DIM                                               !2, 3
         18        OP_DATA                                                  'fake'
   19    19        INIT_FCALL                                               'array_map'
         20        SEND_VAL                                                 'add_regex_finders'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                         $15     
         23        ASSIGN                                                   !3, $15
   20    24        INIT_FCALL                                               'preg_replace'
         25        SEND_VAR                                                 !3
         26        INIT_FCALL                                               'array_map'
         27        DECLARE_LAMBDA_FUNCTION                          ~17     [0]
         28        SEND_VAL                                                 ~17
         29        SEND_VAR                                                 !2
         30        DO_ICALL                                         $18     
         31        SEND_VAR                                                 $18
         32        SEND_VAR                                                 !0
         33        DO_ICALL                                         $19     
         34        ECHO                                                     $19
         35      > RETURN                                                   1


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

End of Dynamic Function 0

Function add_regex_finders:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TDGbJ
function name:  add_regex_finders
number of ops:  5
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        CONCAT                                           ~1      '%2F%28%5B%5Cs%3A%5C%23%5D%29', !0
          2        CONCAT                                           ~2      ~1, '%28%5B%5Cs%3A%5D%29%2Fi'
          3      > RETURN                                                   ~2
   17     4*     > RETURN                                                   null

End of function add_regex_finders

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
230.23 ms | 1004 KiB | 15 Q