3v4l.org

run code in 500+ PHP versions simultaneously
<?php function camelCaseToUnderscore($input) { return ltrim(strtolower(preg_replace('/[A-Z]([A-Z](?![a-z]))*/', '_$0', $input)), '_'); } echo camelCaseToUnderscore('CamelCaseForTheWin'), "\n"; echo camelCaseToUnderscore('ACar'), "\n"; echo camelCaseToUnderscore('BuyACar'), "\n"; echo camelCaseToUnderscore('XML'), "\n"; echo camelCaseToUnderscore('SimpleXML'), "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dIo6c
function name:  (null)
number of ops:  26
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                                   'camelcasetounderscore'
          1        SEND_VAL                                                     'CamelCaseForTheWin'
          2        DO_FCALL                                          0  $0      
          3        ECHO                                                         $0
          4        ECHO                                                         '%0A'
    9     5        INIT_FCALL                                                   'camelcasetounderscore'
          6        SEND_VAL                                                     'ACar'
          7        DO_FCALL                                          0  $1      
          8        ECHO                                                         $1
          9        ECHO                                                         '%0A'
   10    10        INIT_FCALL                                                   'camelcasetounderscore'
         11        SEND_VAL                                                     'BuyACar'
         12        DO_FCALL                                          0  $2      
         13        ECHO                                                         $2
         14        ECHO                                                         '%0A'
   11    15        INIT_FCALL                                                   'camelcasetounderscore'
         16        SEND_VAL                                                     'XML'
         17        DO_FCALL                                          0  $3      
         18        ECHO                                                         $3
         19        ECHO                                                         '%0A'
   12    20        INIT_FCALL                                                   'camelcasetounderscore'
         21        SEND_VAL                                                     'SimpleXML'
         22        DO_FCALL                                          0  $4      
         23        ECHO                                                         $4
         24        ECHO                                                         '%0A'
         25      > RETURN                                                       1

Function camelcasetounderscore:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dIo6c
function name:  camelCaseToUnderscore
number of ops:  12
compiled vars:  !0 = $input
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    5     1        INIT_FCALL                                                   'ltrim'
          2        INIT_FCALL                                                   'strtolower'
          3        FRAMELESS_ICALL_3                preg_replace        ~1      '%2F%5BA-Z%5D%28%5BA-Z%5D%28%3F%21%5Ba-z%5D%29%29%2A%2F', '_%240'
          4        OP_DATA                                                      !0
          5        SEND_VAL                                                     ~1
          6        DO_ICALL                                             $2      
          7        SEND_VAR                                                     $2
          8        SEND_VAL                                                     '_'
          9        DO_ICALL                                             $3      
         10      > RETURN                                                       $3
    6    11*     > RETURN                                                       null

End of function camelcasetounderscore

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
177.68 ms | 2606 KiB | 20 Q