3v4l.org

run code in 500+ 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:  29
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        FETCH_DIM_R                                          ~9      !1, 'slice'
         15        FRAMELESS_ICALL_2                implode             ~10     '_', ~9
         16        ASSIGN_DIM                                                   !1, 'implode'
         17        OP_DATA                                                      ~10
   15    18        INIT_FCALL_BY_NAME                                           'studly_case'
         19        CHECK_FUNC_ARG                                               
         20        FETCH_DIM_FUNC_ARG                                   $12     !1, 'implode'
         21        SEND_FUNC_ARG                                                $12
         22        DO_FCALL                                          0  $13     
         23        ASSIGN_DIM                                                   !1, 'class'
         24        OP_DATA                                                      $13
   17    25        INIT_FCALL                                                   'var_dump'
         26        SEND_VAR                                                     !1
         27        DO_ICALL                                                     
   22    28      > 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:  11
compiled vars:  !0 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   RECV                                                 !0      
   20     1        INIT_FCALL                                                   'ucwords'
          2        FRAMELESS_ICALL_3                str_replace         ~1      <array>, '+'
          3        OP_DATA                                                      !0
          4        SEND_VAL                                                     ~1
          5        DO_ICALL                                             $2      
          6        ASSIGN                                                       !0, $2
   21     7        FRAMELESS_ICALL_3                str_replace         ~4      '+', ''
          8        OP_DATA                                                      !0
          9      > RETURN                                                       ~4
   22    10*     > RETURN                                                       null

End of function studly_case

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
163.92 ms | 2824 KiB | 17 Q