3v4l.org

run code in 300+ PHP versions simultaneously
<?php function do_split($name) { return preg_split('/([A-Z]{2,}|([A-Z][^A-Z]*))/', $name, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); } function convert_case($name) { return implode( '_', array_map( 'strtolower', do_split($name) ) ); } $samples = array( 'FooBar', 'FooBAR', 'FOObar', ); print_r(array_map(function ($name) { return array( 'name' => $name, 'split' => do_split($name), 'converted' => convert_case($name), ); }, $samples));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8ihbN
function name:  (null)
number of ops:  10
compiled vars:  !0 = $samples
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, <array>
   25     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'array_map'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8ihbN%3A25%240'
   31     4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function do_split:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8ihbN
function name:  do_split
number of ops:  9
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'preg_split'
          2        SEND_VAL                                                 '%2F%28%5BA-Z%5D%7B2%2C%7D%7C%28%5BA-Z%5D%5B%5EA-Z%5D%2A%29%29%2F'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 null
          5        SEND_VAL                                                 3
          6        DO_ICALL                                         $1      
          7      > RETURN                                                   $1
    5     8*     > RETURN                                                   null

End of function do_split

Function convert_case:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8ihbN
function name:  convert_case
number of ops:  14
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        INIT_FCALL                                               'implode'
    9     2        SEND_VAL                                                 '_'
   10     3        INIT_FCALL                                               'array_map'
   11     4        SEND_VAL                                                 'strtolower'
   12     5        INIT_FCALL                                               'do_split'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $1      
          8        SEND_VAR                                                 $1
          9        DO_ICALL                                         $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                         $3      
         12      > RETURN                                                   $3
   15    13*     > RETURN                                                   null

End of function convert_case

Function %00%7Bclosure%7D%2Fin%2F8ihbN%3A25%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8ihbN
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   27     1        INIT_ARRAY                                       ~1      !0, 'name'
   28     2        INIT_FCALL                                               'do_split'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        ADD_ARRAY_ELEMENT                                ~1      $2, 'split'
   29     6        INIT_FCALL                                               'convert_case'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0  $3      
          9        ADD_ARRAY_ELEMENT                                ~1      $3, 'converted'
         10      > RETURN                                                   ~1
   31    11*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8ihbN%3A25%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.78 ms | 1394 KiB | 24 Q