文字列 open_door を OpenDoor に変換し、abc_bcd_cde を AbcBcdCde に変換します。
- 【htmlコード】
- ;
-
- 文字列 open_door を OpenDoor に変換し、abc_bcd_cde を AbcBcdCde に変換します
-
- < ;meta name="著者" content="">
-
-
-
-
-
-
- < ; /form>
-
-
コードをコピー
- 【phpコード】/*文字列open_doorをOpenDoorに変換し、abc_bcd_cdeをAbcBcdCdeに変換*/
- if($_POST[sub]=="変換"){
- $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]="_".strto lower($arrar[$i]);
- }
- }
- $ str1 =implode("",$array);
- echo $str1;
- }
- }
- ?>
-
-
-
コードをコピー
|