php字符串首字母转换大小写的实例
2024-08-25 16:09:36
in: 后端程序
首字母变大写: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
//by www.jbxue.com
$foo = 'HelloWorld';
$foo = lcfirst($foo); // helloWorld
$bar = 'HELLO WORLD!';
$bar = lcfirst($bar); // hELLO WORLD!
$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
?>
字母变大写:strtoupper()
字母变小写:strtolower()
最新文章
- webApi上传下载文件
- 程序员能力矩阵 Programmer Competency Matrix
- 自定义View之onMeasure()
- HTML5系列五(Canvas详述)
- APP测试流程
- USACO section1.2 Miking cows
- sql2008“备份集中的数据库备份与现有数据库不同”解决方法
- cenos6.5 64位下PHP远程连接sql server2008成功案例
- video.js不能控制本地视频或者音频播放时长
- 剑指架构师系列-持续集成之Maven+Nexus+Jenkins+git+Spring boot
- 记录一次Orthanc dicom数据异常手动修复
- 网站发布出现“未能找到路径“path\bin\roslyn\csc.exe”....“和拒绝访问的解决办法
- 拯救老旧工程,记桥接SpringMVC与Stripes框架
- R语言模块安装
- Redis 深度历险
- 【Python】socket编程-3
- python第三十五课——生成器
- python 3.x 用户登录重设密码
- 第11月第23天 markedTextRange 崩溃
- shell中调用R语言并传入参数的两种步骤