This article mainly introduced PHP to convert uppercase name to underline segmentation naming, this article explains some not accustomed to capitalization style naming methods such as Pascal naming, the Hump naming method to convert the method, the need for friends can refer to the
Sometimes you need to convert the upper case of a string to _+ lowercase, and you will encounter this problem when you name the variable, directly on the code:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
$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 >= && $ascii _code <=) {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); } |