3v4l.org

run code in 300+ 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:  15
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        INIT_FCALL                                               'preg_replace'
          4        SEND_VAL                                                 '%2F%5BA-Z%5D%28%5BA-Z%5D%28%3F%21%5Ba-z%5D%29%29%2A%2F'
          5        SEND_VAL                                                 '_%240'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $1      
          8        SEND_VAR                                                 $1
          9        DO_ICALL                                         $2      
         10        SEND_VAR                                                 $2
         11        SEND_VAL                                                 '_'
         12        DO_ICALL                                         $3      
         13      > RETURN                                                   $3
    6    14*     > RETURN                                                   null

End of function camelcasetounderscore

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.69 ms | 1469 KiB | 21 Q