3v4l.org

run code in 300+ PHP versions simultaneously
<?php function camelCaseToUnderscore($input) { return strtolower(preg_replace('/(?<!^)[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/J1eMO
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/J1eMO
function name:  camelCaseToUnderscore
number of ops:  11
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'strtolower'
          2        INIT_FCALL                                               'preg_replace'
          3        SEND_VAL                                                 '%2F%28%3F%3C%21%5E%29%5BA-Z%5D%2F'
          4        SEND_VAL                                                 '_%240'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $1      
          7        SEND_VAR                                                 $1
          8        DO_ICALL                                         $2      
          9      > RETURN                                                   $2
    6    10*     > RETURN                                                   null

End of function camelcasetounderscore

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.18 ms | 1441 KiB | 20 Q