您好,欢迎访问一九零五行业门户网

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

这篇文章主要介绍了几个php英文字母大小写转换函数,现在分享给大家,需要的朋友可以参考下
每个单词的首字母转换为大写: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英文字母大小写的转换函数的详细内容。
其它类似信息

推荐信息