php字符串首字母转换大小写的实例分享
php中对字符串首字母进行大小写转换的例子。
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()
php字符串首字母转换大小写的实例分享的更多相关文章
- php字符串首字母转换大小写的实例
in: 后端程序首字母变大写:ucwords() <?php$foo = 'hello world!';$foo = ucwords($foo); // Hello World!$bar = ' ...
- 用Java将字符串的首字母转换大小写
在项目开发的时候会需要统一字符串的格式,比如首字母要求统一大写或小写,那用Java如何实现这一功能?下面一起来学习学习. 话不多说,直接上代码 ? 1 2 3 4 5 6 7 8 9 10 11 12 ...
- Java将字符串的首字母转换大小写
//首字母转小写public static String toLowerCaseFirstOne(String s){ if(Character.isLowerCase(s.charAt(0))) ...
- 【Golang】字符串首字母大小写转化
写在前面 在自动化过程中,我们用得最多的可能就是字符串的处理,熟悉Python的都知道在Python中要让一个字符串的首字母大写直接用capitalize就可以了,但是同样的事情在Golang中没有这 ...
- php 中文字符串首字母的获取函数
这篇文章介绍了php 中文字符串首字母的获取函数,有需要的朋友可以参考一下 function chineseFirst($str) { $str= iconv("UTF-8",&q ...
- ms sql 获取字符串首字母
很久没有编写新文章,现在发布一篇自定义函数,针对于ms sql数据库中需要获取字符串首字母,对于需要的朋友希望对你有用,如果你有更好的方法也可以给我留言.函数如下: --获取字符串首字母 CREATE ...
- sql 获取字符串首字母,循环
//字符串首字母 CREATE FUNCTION GetInitialLetter(@ChineseString NVARCHAR()) RETURNS NVARCHAR() AS BEGIN DEC ...
- YTU 2760: 字符串---首字母变大写
2760: 字符串---首字母变大写 时间限制: 1 Sec 内存限制: 128 MB 提交: 343 解决: 136 题目描述 输入一行英文句子,将每个单词的第一个字母改成大写字母. 输入 一个 ...
- PHP将字符串首字母大小写转换
每个单词的首字母转换为大写:ucwords() <?php $foo = 'hello world!'; $foo = ucwords($foo); // Hello World! $bar = ...
随机推荐
- Cent OS安装TL-WN725N 2.0 USB驱动
TP Link官方没有提供TL-WN725N 2.0的Linux驱动下载,折腾了我半天,试了各种方法.也有一部分原因是因为这机器还不能联网,导致有一些驱动因为缺少依赖并不成功安装. 后来终于在gith ...
- Helpers\ReservedWords
Helpers\ReservedWords This helper returns an array of reserved words, this includes php 7's new rese ...
- Linux 学习笔记 查看文件内容诸多命令
查看文件内容 1.查看文件统计信息 stat 提供文件系统上某个文件的所有状态信息 2.查看文件类型 file 用来查看文件类型 (该命令将文件分成3类:文本类型:可执行文件:数据文件) 如果你有从未 ...
- JavaScript 之 页面跳转及Frame动态加载
一.页面跳转 JS跳转大概有以下五种方式: 1.跳转到B页面 <script language="javascript" type="text/javascript ...
- 沈逸老师PHP魔鬼特训笔记(2)
一.这一课会学习到几个懒人函数: 1.file_put_contents (PHP 5, PHP 7) file_put_contents — 将一个字符串写入文件 说明 int file_put_c ...
- 开发技巧01——改变Toast显示位置
1.获得Toast对象——Toast toast = Toast.makeText(this, "Top Left!", Toast.LENGTH_SHORT); 2.Toast对 ...
- HTML5 indexedDB数据库的入门学习(一)
笔者早些时间看过web sql database,但是不再维护和支持,所以最近初步学习了一下indexedDB数据库,首先indexedDB(简称IDB)和web sql database有很大的差别 ...
- maya 2015配置openCollada插件
1.下载对应的openCollada插件内容 https://github.com/KhronosGroup/OpenCOLLADA/wiki/OpenCOLLADA-Tools 该页面目前提供Mac ...
- LeetCode 75
Sort Colors Given an array with n objects colored red, white or blue, sort them so that objects of t ...
- okhttputils开源库的混淆配置(Eclipse)
#=====================okhttputils框架===================== #====okhttputils==== -libraryjars libs/okht ...