3v4l.org

run code in 300+ PHP versions simultaneously
<?php $file = '2014_10_12_100000_create_password_resets_table'; // Create array of all parts... $steps['explode'] = explode('_', $file); // The expected datetime format as 4 parts, so we remove the first 4 elements and keep the rest. $steps['slice'] = array_slice($steps['explode'], 4); // Implode the remaining elements back together into a snake_case string. $steps['implode'] = implode('_', $steps['slice']); // Convert the snake_case string to a StudlyCase class name. $steps['class'] = studly_case($steps['implode']); var_dump($steps); function studly_case($value) { $value = ucwords(str_replace(['-', '_'], ' ', $value)); return str_replace(' ', '', $value); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k5OlB
function name:  (null)
number of ops:  32
compiled vars:  !0 = $file, !1 = $steps
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '2014_10_12_100000_create_password_resets_table'
    6     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '_'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN_DIM                                               !1, 'explode'
          6        OP_DATA                                                  $4
    9     7        INIT_FCALL                                               'array_slice'
          8        FETCH_DIM_R                                      ~6      !1, 'explode'
          9        SEND_VAL                                                 ~6
         10        SEND_VAL                                                 4
         11        DO_ICALL                                         $7      
         12        ASSIGN_DIM                                               !1, 'slice'
         13        OP_DATA                                                  $7
   12    14        INIT_FCALL                                               'implode'
         15        SEND_VAL                                                 '_'
         16        FETCH_DIM_R                                      ~9      !1, 'slice'
         17        SEND_VAL                                                 ~9
         18        DO_ICALL                                         $10     
         19        ASSIGN_DIM                                               !1, 'implode'
         20        OP_DATA                                                  $10
   15    21        INIT_FCALL_BY_NAME                                       'studly_case'
         22        CHECK_FUNC_ARG                                           
         23        FETCH_DIM_FUNC_ARG                               $12     !1, 'implode'
         24        SEND_FUNC_ARG                                            $12
         25        DO_FCALL                                      0  $13     
         26        ASSIGN_DIM                                               !1, 'class'
         27        OP_DATA                                                  $13
   17    28        INIT_FCALL                                               'var_dump'
         29        SEND_VAR                                                 !1
         30        DO_ICALL                                                 
   22    31      > RETURN                                                   1

Function studly_case:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k5OlB
function name:  studly_case
number of ops:  17
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        INIT_FCALL                                               'ucwords'
          2        INIT_FCALL                                               'str_replace'
          3        SEND_VAL                                                 <array>
          4        SEND_VAL                                                 '+'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $1      
          7        SEND_VAR                                                 $1
          8        DO_ICALL                                         $2      
          9        ASSIGN                                                   !0, $2
   21    10        INIT_FCALL                                               'str_replace'
         11        SEND_VAL                                                 '+'
         12        SEND_VAL                                                 ''
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $4      
         15      > RETURN                                                   $4
   22    16*     > RETURN                                                   null

End of function studly_case

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.98 ms | 1024 KiB | 19 Q