3v4l.org

run code in 300+ PHP versions simultaneously
<?php function camelCase($str) { $i = array("-","_"); $str = preg_replace('/([a-z])([A-Z])/', "\\1 \\2", $str); $str = preg_replace('@[^a-zA-Z0-9\-_ ]+@', '', $str); $str = str_replace($i, ' ', $str); $str = str_replace(' ', '', ucwords(strtolower($str))); $str = strtolower(substr($str,0,1)).substr($str,1); return $str; } function uncamelCase($str) { $str = preg_replace('/([a-z])([A-Z])/', "\\1_\\2", $str); $str = strtolower($str); return $str; } $camel = camelCase("James_LIKES-camelCase"); $uncamel = uncamelCase($camel); echo $camel." ".$uncamel;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9F3PB
function name:  (null)
number of ops:  12
compiled vars:  !0 = $camel, !1 = $uncamel
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'camelcase'
          1        SEND_VAL                                                 'James_LIKES-camelCase'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
   19     4        INIT_FCALL                                               'uncamelcase'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0  $4      
          7        ASSIGN                                                   !1, $4
   20     8        CONCAT                                           ~6      !0, '+'
          9        CONCAT                                           ~7      ~6, !1
         10        ECHO                                                     ~7
   21    11      > RETURN                                                   1

Function camelcase:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9F3PB
function name:  camelCase
number of ops:  48
compiled vars:  !0 = $str, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'preg_replace'
          3        SEND_VAL                                                 '%2F%28%5Ba-z%5D%29%28%5BA-Z%5D%29%2F'
          4        SEND_VAL                                                 '%5C1+%5C2'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !0, $3
    6     8        INIT_FCALL                                               'preg_replace'
          9        SEND_VAL                                                 '%40%5B%5Ea-zA-Z0-9%5C-_+%5D%2B%40'
         10        SEND_VAL                                                 ''
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $5      
         13        ASSIGN                                                   !0, $5
    7    14        INIT_FCALL                                               'str_replace'
         15        SEND_VAR                                                 !1
         16        SEND_VAL                                                 '+'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $7      
         19        ASSIGN                                                   !0, $7
    8    20        INIT_FCALL                                               'str_replace'
         21        SEND_VAL                                                 '+'
         22        SEND_VAL                                                 ''
         23        INIT_FCALL                                               'ucwords'
         24        INIT_FCALL                                               'strtolower'
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                         $9      
         27        SEND_VAR                                                 $9
         28        DO_ICALL                                         $10     
         29        SEND_VAR                                                 $10
         30        DO_ICALL                                         $11     
         31        ASSIGN                                                   !0, $11
    9    32        INIT_FCALL                                               'strtolower'
         33        INIT_FCALL                                               'substr'
         34        SEND_VAR                                                 !0
         35        SEND_VAL                                                 0
         36        SEND_VAL                                                 1
         37        DO_ICALL                                         $13     
         38        SEND_VAR                                                 $13
         39        DO_ICALL                                         $14     
         40        INIT_FCALL                                               'substr'
         41        SEND_VAR                                                 !0
         42        SEND_VAL                                                 1
         43        DO_ICALL                                         $15     
         44        CONCAT                                           ~16     $14, $15
         45        ASSIGN                                                   !0, ~16
   10    46      > RETURN                                                   !0
   11    47*     > RETURN                                                   null

End of function camelcase

Function uncamelcase:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9F3PB
function name:  uncamelCase
number of ops:  13
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%2F%28%5Ba-z%5D%29%28%5BA-Z%5D%29%2F'
          3        SEND_VAL                                                 '%5C1_%5C2'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6        ASSIGN                                                   !0, $1
   14     7        INIT_FCALL                                               'strtolower'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $3      
         10        ASSIGN                                                   !0, $3
   15    11      > RETURN                                                   !0
   16    12*     > RETURN                                                   null

End of function uncamelcase

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.85 ms | 1013 KiB | 20 Q