3v4l.org

run code in 300+ PHP versions simultaneously
<?php function snakeToCamel($string) { $words = explode('_', $string); $camel = ''; foreach ($words as $word) { $camel .= ucfirst($word); } return $camel; } /** * underdash_separated -> camelCase. * @param string * @return string */ function underdashToCamel($s) { $s = strtolower($s); $s = preg_replace('#_(?=[a-z])#', ' ', $s); $s = substr(ucwords('x' . $s), 1); $s = str_replace(' ', '', $s); return $s; } echo snakeToCamel("ahoj_vole_todle_1_je_PECKE__") . "\n"; echo underdashToCamel("ahoj_vole_todle_1_je_PECKE__") . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oBCMq
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                               'snaketocamel'
          1        SEND_VAL                                                 'ahoj_vole_todle_1_je_PECKE__'
          2        DO_FCALL                                      0  $0      
          3        CONCAT                                           ~1      $0, '%0A'
          4        ECHO                                                     ~1
   33     5        INIT_FCALL                                               'underdashtocamel'
          6        SEND_VAL                                                 'ahoj_vole_todle_1_je_PECKE__'
          7        DO_FCALL                                      0  $2      
          8        CONCAT                                           ~3      $2, '%0A'
          9        ECHO                                                     ~3
         10      > RETURN                                                   1

Function snaketocamel:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/oBCMq
function name:  snakeToCamel
number of ops:  17
compiled vars:  !0 = $string, !1 = $words, !2 = $camel, !3 = $word
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '_'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
    6     6        ASSIGN                                                   !2, ''
    7     7      > FE_RESET_R                                       $7      !1, ->14
          8    > > FE_FETCH_R                                               $7, !3, ->14
    8     9    >   INIT_FCALL                                               'ucfirst'
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                         $8      
         12        ASSIGN_OP                                     8          !2, $8
    7    13      > JMP                                                      ->8
         14    >   FE_FREE                                                  $7
   10    15      > RETURN                                                   !2
   11    16*     > RETURN                                                   null

End of function snaketocamel

Function underdashtocamel:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oBCMq
function name:  underdashToCamel
number of ops:  28
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   21     1        INIT_FCALL                                               'strtolower'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
   22     5        INIT_FCALL                                               'preg_replace'
          6        SEND_VAL                                                 '%23_%28%3F%3D%5Ba-z%5D%29%23'
          7        SEND_VAL                                                 '+'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $3      
         10        ASSIGN                                                   !0, $3
   23    11        INIT_FCALL                                               'substr'
         12        INIT_FCALL                                               'ucwords'
         13        CONCAT                                           ~5      'x', !0
         14        SEND_VAL                                                 ~5
         15        DO_ICALL                                         $6      
         16        SEND_VAR                                                 $6
         17        SEND_VAL                                                 1
         18        DO_ICALL                                         $7      
         19        ASSIGN                                                   !0, $7
   24    20        INIT_FCALL                                               'str_replace'
         21        SEND_VAL                                                 '+'
         22        SEND_VAL                                                 ''
         23        SEND_VAR                                                 !0
         24        DO_ICALL                                         $9      
         25        ASSIGN                                                   !0, $9
   26    26      > RETURN                                                   !0
   27    27*     > RETURN                                                   null

End of function underdashtocamel

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.2 ms | 1403 KiB | 29 Q