3v4l.org

run code in 300+ PHP versions simultaneously
<?php $keywords = [ 0=>['id'=>1,'slug'=>'getName','url'=>'https://www.getname.com'], 1=>['id'=>2,'slug'=>'testName','url'=>'https://www.testname.com'], 2=>['id'=>3,'slug'=>'ign','url'=>'https://www.ign.com'], ]; $str = "<p>Just a test: getName testName"; echo array_reduce($keywords, function ($c, $v) { return preg_replace('/\\b(' . $v['slug'] . ')\\b/', $v['url'], $c); }, $str);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VsDLQ
function name:  (null)
number of ops:  10
compiled vars:  !0 = $keywords, !1 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    7     1        ASSIGN                                                   !1, '%3Cp%3EJust+a+test%3A+getName++testName'
    8     2        INIT_FCALL                                               'array_reduce'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          5        SEND_VAL                                                 ~4
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $5      
          8        ECHO                                                     $5
          9      > 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/VsDLQ
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $c, !1 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        INIT_FCALL                                               'preg_replace'
          3        FETCH_DIM_R                                      ~2      !1, 'slug'
          4        CONCAT                                           ~3      '%2F%5Cb%28', ~2
          5        CONCAT                                           ~4      ~3, '%29%5Cb%2F'
          6        SEND_VAL                                                 ~4
          7        FETCH_DIM_R                                      ~5      !1, 'url'
          8        SEND_VAL                                                 ~5
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $6      
         11      > RETURN                                                   $6
         12*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.82 ms | 1438 KiB | 15 Q