php中几个字符函数小结
程序员文章站
2022-04-17 19:03:11
...
下面小结PHP中的几个字符函数,小结一下:
1)ucfirst
将首字母变大写,比如
$string = "this is my web development blog";
echo ucfirst($string);
// Output: This is my web development blog
2) lcfirst,将首字母变小写
$string = "This is my Web Development Blog";
echo lcfirst($string);
// Output: this is my Web Development Blog
3)strtoupper,将整个字符串变大写
$string = "this is my web development blog";
echo strtoupper($string);
// Output: THIS IS MY WEB DEVELOPMENT BLOG
4) strtoplower,将整个字符串变小写
$string = "tHiS is mY WeB DevElOpMenT bLoG";
echo strtolower($string);
// Output: this is my web development blog
5)ucwords(),可以将句子中每个单词的第一个字母变大写,比如
$string = "this is my web development blog";
echo ucwords($string);
// Output: This Is My Web Development Blog
1)ucfirst
将首字母变大写,比如
$string = "this is my web development blog";
echo ucfirst($string);
// Output: This is my web development blog
2) lcfirst,将首字母变小写
$string = "This is my Web Development Blog";
echo lcfirst($string);
// Output: this is my Web Development Blog
3)strtoupper,将整个字符串变大写
$string = "this is my web development blog";
echo strtoupper($string);
// Output: THIS IS MY WEB DEVELOPMENT BLOG
4) strtoplower,将整个字符串变小写
$string = "tHiS is mY WeB DevElOpMenT bLoG";
echo strtolower($string);
// Output: this is my web development blog
5)ucwords(),可以将句子中每个单词的第一个字母变大写,比如
$string = "this is my web development blog";
echo ucwords($string);
// Output: This Is My Web Development Blog
上一篇: 对面向对象的思考。
下一篇: UNIX系统属于哪一类操作系统
推荐阅读
-
【PHP】array_walk_recursive ― 对数组中的每个成员递归地施用用户函数
-
PHP中的排序函数sort、asort、rsort、krsort、ksort区别分析_PHP
-
利用PHP函数计算中英文字符串长度的方法,_PHP教程
-
PHP中通过HTTP_USER_AGENT判断是否为手机移动终端的函数代码_PHP
-
PHP中ob_start函数的使用说明_PHP教程
-
Python常见字符串操作函数小结【split()、join()、strip()】
-
php在字符串中查找另一个字符串
-
php substr()函数截取中文字符串乱码
-
php写的将逗号、空格、回车分隔的字符串转换为数组的函数
-
浅析51个PHP处理字符串的函数