3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ 'MY_TABLE' => 'MyTable', 'MyTable' => 'MyTable', 'my_table' => 'MyTable', 'myTable' => 'MyTable', ]; function yiiCamelize($word) { return str_replace(' ', '', ucwords(preg_replace('/[^\pL\pN]+/u', ' ', $word))); } function camelCaseIt($input) { return strtr(ucwords(implode(' ', explode('_', strtolower(strtr(yiiCamelize($input), [' ' => '_']))))), [' ' => '']); } foreach ($data as $input => $expected) { $actual = camelCaseIt($input); if ($actual === $expected) { echo '.'; } else { echo 'F(' . $actual . ')'; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 16
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/164si
function name:  (null)
number of ops:  18
compiled vars:  !0 = $data, !1 = $expected, !2 = $input, !3 = $actual
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   19     1      > FE_RESET_R                                       $5      !0, ->16
          2    > > FE_FETCH_R                                       ~6      $5, !1, ->16
          3    >   ASSIGN                                                   !2, ~6
   20     4        INIT_FCALL                                               'camelcaseit'
          5        SEND_VAR                                                 !2
          6        DO_FCALL                                      0  $8      
          7        ASSIGN                                                   !3, $8
   21     8        IS_IDENTICAL                                             !3, !1
          9      > JMPZ                                                     ~10, ->12
   22    10    >   ECHO                                                     '.'
   21    11      > JMP                                                      ->15
   24    12    >   CONCAT                                           ~11     'F%28', !3
         13        CONCAT                                           ~12     ~11, '%29'
         14        ECHO                                                     ~12
   19    15    > > JMP                                                      ->2
         16    >   FE_FREE                                                  $5
   26    17      > RETURN                                                   1

Function yiicamelize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/164si
function name:  yiiCamelize
number of ops:  16
compiled vars:  !0 = $word
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 '+'
          3        SEND_VAL                                                 ''
          4        INIT_FCALL                                               'ucwords'
          5        INIT_FCALL                                               'preg_replace'
          6        SEND_VAL                                                 '%2F%5B%5E%5CpL%5CpN%5D%2B%2Fu'
          7        SEND_VAL                                                 '+'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $1      
         10        SEND_VAR                                                 $1
         11        DO_ICALL                                         $2      
         12        SEND_VAR                                                 $2
         13        DO_ICALL                                         $3      
         14      > RETURN                                                   $3
   12    15*     > RETURN                                                   null

End of function yiicamelize

Function camelcaseit:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/164si
function name:  camelCaseIt
number of ops:  28
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        INIT_FCALL                                               'strtr'
          2        INIT_FCALL                                               'ucwords'
          3        INIT_FCALL                                               'implode'
          4        SEND_VAL                                                 '+'
          5        INIT_FCALL                                               'explode'
          6        SEND_VAL                                                 '_'
          7        INIT_FCALL                                               'strtolower'
          8        INIT_FCALL                                               'strtr'
          9        INIT_FCALL                                               'yiicamelize'
         10        SEND_VAR                                                 !0
         11        DO_FCALL                                      0  $1      
         12        SEND_VAR                                                 $1
         13        SEND_VAL                                                 <array>
         14        DO_ICALL                                         $2      
         15        SEND_VAR                                                 $2
         16        DO_ICALL                                         $3      
         17        SEND_VAR                                                 $3
         18        DO_ICALL                                         $4      
         19        SEND_VAR                                                 $4
         20        DO_ICALL                                         $5      
         21        SEND_VAR                                                 $5
         22        DO_ICALL                                         $6      
         23        SEND_VAR                                                 $6
         24        SEND_VAL                                                 <array>
         25        DO_ICALL                                         $7      
         26      > RETURN                                                   $7
   17    27*     > RETURN                                                   null

End of function camelcaseit

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.25 ms | 1440 KiB | 22 Q