PHP将字符串首字母大小写转换
2024-08-26 07:52:47
每个单词的首字母转换为大写:ucwords()
<?php
$foo = 'hello world!';
$foo = ucwords($foo); // Hello World! $bar = 'HELLO WORLD!';
$bar = ucwords($bar); // HELLO WORLD!
$bar = ucwords(strtolower($bar)); // Hello World!
?>
第一个单词首字母变大写:ucfirst()
<?php
$foo = 'hello world!';
$foo = ucfirst($foo); // Hello world! $bar = 'HELLO WORLD!';
$bar = ucfirst($bar); // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>
第一个单词首字母变小写:lcfirst()
<?php
$foo = 'HelloWorld';
$foo = lcfirst($foo); // helloWorld $bar = 'HELLO WORLD!';
$bar = lcfirst($bar); // hELLO WORLD!
$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
?>
所有 字母变大写:strtoupper()
所有 字母变小写:strtolower()
最新文章
- 在Windows7上如何找到Cookie(亲测100%可找到)
- Git的奇技淫巧&#128584;
- Effective C++ 之 Item 5:了解C++默默编写并调用哪些函数
- Chp18: Hard
- C#学习笔记---基础入门(三)
- Servlet3.0学习总结(一)——使用注解标注Servlet
- Cocos2d-x内存自动释放机制--透彻篇
- SQL Server2008 附加数据库失败 错误代码5120
- Contest20140705 testA 二分
- memcache锁
- 你能相信吗?这些都是由一个DIV元素实现的动画,纯CSS3技术
- 4天html总结
- Java 字节流操作
- 网络流24题 P1251 餐巾计划问题 拆点
- adb push 中文路径文件名丢失后缀
- Idea使用Maven创建Java Web项目
- CNN卷积核反传分析
- Keil5下载STM32库
- centos内存自动清理脚本及限制tomcat内存占用
- [Linux]如何查看系统的Time Slice