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将字符串首字母大小写转换的更多相关文章
- 【Golang】字符串首字母大小写转化
写在前面 在自动化过程中,我们用得最多的可能就是字符串的处理,熟悉Python的都知道在Python中要让一个字符串的首字母大写直接用capitalize就可以了,但是同样的事情在Golang中没有这 ...
- 使用fastJson把对象转字符串首字母大小写问题的解决
例如:文档中要求传输的字段为 但是转成json字符串后却变成了: 解决方式: 在实体类的get方法上添加@JSONField(name = " ") 注解后问题解决: 输出:
- php字符串首字母转换大小写的实例分享
php中对字符串首字母进行大小写转换的例子. in: 后端程序首字母变大写:ucwords() <?php $foo = 'hello world!'; $foo = ucwords($foo) ...
- php 字母大小写转换的函数
分享下,在php编程中,将字母大小写进行转换的常用函数. 1.将字符串转换成小写strtolower(): 该函数将传入的字符串参数所有的字符都转换成小写,并以小定形式放回这个字符串 2.将字符转成大 ...
- AS3.0 字母大小写转换
字母大小写转换: /** * * *-------------------------* * | *** 字母大小写转换 *** | * *-------------------------* * * ...
- js中实现字母大小写转换
js中实现字母大小写转换主要用到了四个js函数: 1.toLocaleUpperCase 2.toUpperCase3.toLocaleLowerCase4.toLowerCase 下面就这四个实现 ...
- java string 首字母大小写方法
String字符串需要进行首字母大小写改写,查询google,就是将首字母截取,转化大小写 + 首字母后面字符串 //首字母小写 public static String captureName(St ...
- ASP.NET Core中返回 json 数据首字母大小写问题
ASP.NET Core中返回 json 数据首字母大小写问题 在asp.net core中使用ajax请求动态绑定数据时遇到该问题 后台返回数据字段首字母为定义的大写,返回的数据没有问题 但是在前台 ...
- php 中文字符串首字母的获取函数
这篇文章介绍了php 中文字符串首字母的获取函数,有需要的朋友可以参考一下 function chineseFirst($str) { $str= iconv("UTF-8",&q ...
随机推荐
- Spring - IoC(2): 属性注入 & 构造注入
依赖注入是指程序运行过程中,如果需要另外的对象协作(访问它的属性或调用它的方法)时,无须在代码中创建被调用者,而是依赖于外部容器的注入. 属性注入(Setter Injection) 属性注入是指 I ...
- css划斜线
http://stackoverflow.com/questions/18012420/draw-diagonal-lines-in-div-background-with-css
- 谈pkusc2016的几道数学题
题面搬来的qwq(忘记出处了 水印应该能表示) [题解] 1. 我们看到这题先想到令(x+y+z)^3 展开得到一坨,稍微减减,得到我们要求证 delta = 3xy^2+3xz^2+3yx^2+3y ...
- ecma 2018, javascript spread syntax behaves like Object.assign
as the subject. It is only supported in Chrome version 60+, so, first check the version, or just use ...
- [转载]超赞!32款扁平化Photoshop PSD UI工具包(下)
32款扁平化风格的UI工具包第二弹!上篇为大家分享了16款风格各异的UI Kits,下篇继续为大家呈上16款精美的UI工具包,全部都有Photoshop PSD文件可以下载哦,喜欢就赶紧收藏吧! 17 ...
- DotNETCore 学习笔记 宿主
Hosting -------------------------------------------------------------------------- Setting up a Host ...
- hdu 2899 Strange fuction (二分)
题目链接:http://acm.hdu.edu.cn/showproblem.pihp?pid=2899 题目大意:找出满足F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x ( ...
- Javascript传参参考
可参考的细节: <!doctype html> <html lang="en"> <head> <meta charset="U ...
- 推荐下载App,如果本地安装则直接打开本地App(Android/IOS)
推荐下载App,如果本地安装则直接打开本地App(Android/IOS) - 纵观现在每家移动网站,打开首页的时候,都有各种各样的形式来提示你下载自身的移动App(Android/IOS),这是做移 ...
- docker从零开始 存储(三)bind mounts
使用bind mounts 自Docker早期以来bind mounts 一直存在.与volumes相比,绑定挂载具有有限的功能.使用bind mounts时,主机上的文件或目录将装入容器中.文件或目 ...