3v4l.org

run code in 300+ PHP versions simultaneously
<?php function smart_uc_words($string) { $string = strtolower(trim($string)); // Capitalise any word char preceded by a non-word char other than an apostrophe $string = preg_replace_callback('/(?<!\w|\')(\w)/', function($m){ return strtoupper($m[1]); }, $string); // Capitalise any word char which comes between an apostrophe and another word char $string = preg_replace_callback('/(?<=\')(\w)(?=\w)/', function($m){ return strtoupper($m[1]); }, $string); return $string; } echo smart_uc_words("s'hertogengebosch");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JDqeq
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'smart_uc_words'
          1        SEND_VAL                                                 's%27hertogengebosch'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function smart_uc_words:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JDqeq
function name:  smart_uc_words
number of ops:  24
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'strtolower'
          2        INIT_FCALL                                               'trim'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5        SEND_VAR                                                 $1
          6        DO_ICALL                                         $2      
          7        ASSIGN                                                   !0, $2
    7     8        INIT_FCALL                                               'preg_replace_callback'
          9        SEND_VAL                                                 '%2F%28%3F%3C%21%5Cw%7C%27%29%28%5Cw%29%2F'
         10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FJDqeq%3A7%240'
         11        SEND_VAL                                                 ~4
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $5      
         14        ASSIGN                                                   !0, $5
    9    15        INIT_FCALL                                               'preg_replace_callback'
         16        SEND_VAL                                                 '%2F%28%3F%3C%3D%27%29%28%5Cw%29%28%3F%3D%5Cw%29%2F'
         17        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FJDqeq%3A9%241'
         18        SEND_VAL                                                 ~7
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $8      
         21        ASSIGN                                                   !0, $8
   11    22      > RETURN                                                   !0
   12    23*     > RETURN                                                   null

End of function smart_uc_words

Function %00%7Bclosure%7D%2Fin%2FJDqeq%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JDqeq
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'strtoupper'
          2        FETCH_DIM_R                                      ~1      !0, 1
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5      > RETURN                                                   $2
          6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FJDqeq%3A7%240

Function %00%7Bclosure%7D%2Fin%2FJDqeq%3A9%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JDqeq
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'strtoupper'
          2        FETCH_DIM_R                                      ~1      !0, 1
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5      > RETURN                                                   $2
          6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FJDqeq%3A9%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.1 ms | 1402 KiB | 22 Q