3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ 'a' => 'food', 'b' => 'foo', 'c' => 'goo', 'd' => 'foo', 'e' => 'good' ]; $needle = 'foo'; $newValue = 'bar'; function array_replace_value(&$ar, $value, $replacement) { $ar = preg_replace('#^' . preg_quote($value) . '$#', $replacement, $ar); } array_replace_value($array, $needle, $newValue); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HacTL
function name:  (null)
number of ops:  12
compiled vars:  !0 = $array, !1 = $needle, !2 = $newValue
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   11     1        ASSIGN                                                       !1, 'foo'
   12     2        ASSIGN                                                       !2, 'bar'
   19     3        INIT_FCALL                                                   'array_replace_value'
          4        SEND_REF                                                     !0
          5        SEND_VAR                                                     !1
          6        SEND_VAR                                                     !2
          7        DO_FCALL                                          0          
   20     8        INIT_FCALL                                                   'var_export'
          9        SEND_VAR                                                     !0
         10        DO_ICALL                                                     
         11      > RETURN                                                       1

Function array_replace_value:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HacTL
function name:  array_replace_value
number of ops:  12
compiled vars:  !0 = $ar, !1 = $value, !2 = $replacement
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   16     3        INIT_FCALL                                                   'preg_quote'
          4        SEND_VAR                                                     !1
          5        DO_ICALL                                             $3      
          6        CONCAT                                               ~4      '%23%5E', $3
          7        CONCAT                                               ~5      ~4, '%24%23'
          8        FRAMELESS_ICALL_3                preg_replace        ~6      ~5, !2
          9        OP_DATA                                                      !0
         10        ASSIGN                                                       !0, ~6
   17    11      > RETURN                                                       null

End of function array_replace_value

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
176.86 ms | 1461 KiB | 18 Q