Convert the string open_door to OpenDoor, and convert abc_bcd_cde to AbcBcdCde
- 【html code】
-
- Convert the string open_door to OpenDoor, and convert abc_bcd_cde to AbcBcdCde
-
-
-
-
-
-
-
-
-
- < ;/form>
-
Copy code
-
- 【php code】/*Convert the string open_door to OpenDoor, and convert abc_bcd_cde to AbcBcdCde*/
- if($_POST[sub]=="Convert"){
- $string= $_POST[string];
- if(strstr($string,"_"))
- {
- $arr=explode("_",$string);
- //print_r($arr);
- for($i= 0;$i {
- $arr[$i]=ucfirst($arr[$i]);
- }
- $str=implode("",$arr);
- echo $str;
- }
- else
- {
- $array=str_split($string);
- for($i=0 ;$i {
- $str=ucfirst($array [$i]);
- if($str==$array[$i])
- {
- $array[$i]="_".strtolower($arrar[$i]);
- }
- }
- $ str1=implode("",$array);
- echo $str1;
- }
- }
- ?>
-
-
Copy code
|