PHP英文字母大小写转换函数小结


Posted in PHP onMay 03, 2014

每个单词的首字母转换为大写: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()

PHP 相关文章推荐
php+mysql分页代码详解
Mar 27 PHP
ajax+php打造进度条 readyState各状态
Mar 20 PHP
PHP 函数执行效率的小比较
Oct 17 PHP
PHP学习之正则表达式
Apr 17 PHP
php中存储用户ID和密码到mysql数据库的方法
Feb 06 PHP
一个PHP的远程图片抓取函数分享
Sep 25 PHP
神盾加密解密教程(一)PHP变量可用字符
May 28 PHP
php一维二维数组键排序方法实例总结
Nov 13 PHP
smarty内置函数section的用法
Jan 22 PHP
yii2 url重写并隐藏index.php方法
Dec 10 PHP
PHP7数组的底层实现示例
Aug 25 PHP
解决PhpStorm64不能启动的问题
Jun 20 PHP
php获取网卡的MAC地址支持WIN/LINUX系统
Apr 30 #PHP
php环境无法上传文件的解决方法
Apr 30 #PHP
php分页示例分享
Apr 30 #PHP
yii框架配置默认controller和action示例
Apr 30 #PHP
yii框架通过控制台命令创建定时任务示例
Apr 30 #PHP
yii框架builder、update、delete使用方法
Apr 30 #PHP
yii框架表单模型使用及以数组形式提交表单数据示例
Apr 30 #PHP
You might like
PHP脚本中include文件出错解决方法
2008/11/20 PHP
php预定义变量使用帮助(带实例)
2013/10/30 PHP
php define的第二个参数使用方法
2013/11/04 PHP
基于jquery实现的一个选择中国大学的弹框 (数据、步骤、代码)
2012/07/26 Javascript
用jQuery实现一些导航条切换,显示隐藏的实例代码
2013/06/08 Javascript
ff下JQuery无法监听input的keyup事件的解决方法
2013/12/12 Javascript
jQuery中toggle()函数的使用实例
2015/04/17 Javascript
jQuery实现html元素拖拽
2015/07/21 Javascript
再次谈论Javascript中的this
2016/06/23 Javascript
Bootstrap 网站实例之单页营销网站
2016/10/20 Javascript
Vue开发过程中遇到的疑惑知识点总结
2017/01/20 Javascript
element上传组件循环引用及简单时间倒计时的实现
2018/10/01 Javascript
使用原生JS实现火锅点餐小程序(面向对象思想)
2019/12/10 Javascript
Vue-axios-post数据后端接不到问题解决
2020/01/09 Javascript
[07:48]DOTA2上海特级锦标赛主赛事首日RECAP
2016/03/04 DOTA
[52:52]完美世界DOTA2联赛PWL S3 LBZS vs access 第一场 12.10
2020/12/13 DOTA
[55:35]DOTA2-DPC中国联赛 正赛 CDEC vs Dragon BO3 第二场 1月22日
2021/03/11 DOTA
python正则表达式re模块详解
2014/06/25 Python
对python For 循环的三种遍历方式解析
2019/02/01 Python
Python中psutil的介绍与用法
2019/05/02 Python
python tkinter图形界面代码统计工具
2019/09/18 Python
python FTP批量下载/删除/上传实例
2019/12/22 Python
Python3实现mysql连接和数据框的形成(实例代码)
2020/01/17 Python
Python连接Oracle之环境配置、实例代码及报错解决方法详解
2020/02/11 Python
Python结合百度语音识别实现实时翻译软件的实现
2021/01/18 Python
苹果美国官方商城:Apple美国
2016/08/24 全球购物
如何选择使用结构还是类
2014/05/30 面试题
酒店个人培训自我鉴定
2013/12/11 职场文书
2014年教师业务学习材料
2014/05/12 职场文书
班主任师德师风自我剖析材料
2014/10/02 职场文书
大学辅导员述职报告
2015/01/10 职场文书
2015年秋季学校开学标语
2015/07/16 职场文书
交通安全主题班会
2015/08/12 职场文书
Python办公自动化之教你如何用Python将任意文件转为PDF格式
2021/06/28 Python
C#连接ORACLE出现乱码问题的解决方法
2021/10/05 Oracle
vue项目支付功能代码详解
2022/02/18 Vue.js