How to convert uppercase names to underscore separated names in php

墨辰丷
Release: 2023-03-31 14:50:01
Original
1984 people have browsed it

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); }
Copy after login

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.

Related recommendations:

PHP implements the function of dynamically adding image watermarks according to the color environment

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!