老师帮忙看看,谢谢
来源:1-16 编程练习
慕前端3421660
2018-12-12 12:29:17
<?php
$str1='FunCTION_deFINe_TYpe';
$str2=strtolower($str1);
$str2=str_replace('_','',$str1);
$str3=ucwords($str2);
$str4=str_replace('','_',$str3);
echo $str4;
1回答
您好,在第一次使用str_replace函数时应该是操作$str2变量。另在替换时应该使用一个空格进行替换,如果是空字符串,就无法判断之后单词的首字母了哦~
<?php $str1='FunCTION_deFINe_TYpe'; $str2=strtolower($str1); $str2=str_replace('_',' ',$str2); $str3=ucwords($str2); $str4=str_replace(' ','_',$str3); echo $str4;
祝学习愉快!
相似问题