3v4l.org

run code in 300+ PHP versions simultaneously
<?php function replace_spaces ($text) { function replacement ($matches) { return str_replace ($matches[1], ' ', '&nbsp;').' '; } return preg_replace_callback ('/( +) /', 'replacement', $text); } echo replace_spaces('hello world'); echo replacement(array('one','two','three'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dtPIC
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'replace_spaces'
          1        SEND_VAL                                                 'hello+world'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   12     4        INIT_FCALL_BY_NAME                                       'replacement'
          5        SEND_VAL_EX                                              <array>
          6        DO_FCALL                                      0  $1      
          7        ECHO                                                     $1
          8      > RETURN                                                   1

Function replace_spaces:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dtPIC
function name:  replace_spaces
number of ops:  9
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        DECLARE_FUNCTION                                         'replacement'
    7     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAL                                                 '%2F%28+%2B%29+%2F'
          4        SEND_VAL                                                 'replacement'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $1      
          7      > RETURN                                                   $1
    8     8*     > RETURN                                                   null

End of function replace_spaces

Function %00replacement%2Fin%2FdtPIC%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dtPIC
function name:  replacement
number of ops:  10
compiled vars:  !0 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'str_replace'
          2        FETCH_DIM_R                                      ~1      !0, 1
          3        SEND_VAL                                                 ~1
          4        SEND_VAL                                                 '+'
          5        SEND_VAL                                                 '%26nbsp%3B'
          6        DO_ICALL                                         $2      
          7        CONCAT                                           ~3      $2, '+'
          8      > RETURN                                                   ~3
    6     9*     > RETURN                                                   null

End of function %00replacement%2Fin%2FdtPIC%3A4%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.91 ms | 1399 KiB | 18 Q