


How to convert uppercase names to underscore separated names in php
Jun 11, 2018 pm 02:10 PMThis 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<strlen($name);$i++){ $ascii_code = ord($name[$i]); if($ascii_code >= 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!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
