This article mainly introduces how PHP converts uppercase naming into underscore-separated naming. This article explains how to convert some naming methods that are not accustomed to the uppercase style, such as Pascal naming and camel case naming. Friends who need it can refer to it
Sometimes it is necessary to convert the uppercase characters in a string to _ lowercase. You will encounter this problem when naming variables. Just enter the code:
$name = 'AppPromoZhongQiu2014ActiveStatusSelector'; echo cc_format($name); function cc_format($name){ $temp_array = array(); for($i=0;$i= 65 && $ascii_code <= 90){ if($i == 0){ $temp_array[] = chr($ascii_code + 32); }else{ $temp_array[] = '_'.chr($ascii_code + 32); } }else{ $temp_array[] = $name[$i]; } } return implode('',$temp_array); }
Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
The role and usage of type prompts in PHP
PHP implements the function of capturing pictures from online albums with anti-leeching settings
The above is the detailed content of How to convert uppercase names to underscore separated names in php. For more information, please follow other related articles on the PHP Chinese website!