第 3 章 Function Reference

简介:

3.1. String 字符串操作

3.1.1. 英文大小写

1.将字符串转换成小写

strtolower(): 该函数将传入的字符串参数所有的字符都转换成小写,并以小定形式放回这个字符串

2.将字符转成大写

strtoupper(): 该函数的作用同strtolower函数相反,是将传入的字符参数的字符全部转换成大写,并以大写的形式返回这个字符串.用法同strtolowe()一 样.

3.将字符串首字符转换成大写

ucfirst(): 该函数的作用是将字符串的第一个字符改成大写,该函数返回首字符大写的字符串.用法同strtolowe()一样.


4.将字符串每个单词的首字符转换成大写

ucwords(): 该函数将传入的字符串的每个单词的首字符变成大写.如"hello world",经过该函数处理后,将返回"Hello Word".用法同strtolowe()一样.

		

3.1.2. sprintf

		
$str = "Hello";
$number = 123;
$txt = sprintf("%s world. Day number %u",$str,$number);
echo $txt;
		
		

3.1.3. str_replace

$search  = array('one', 'two', 'three');
$replace = array('1',  '2', '3']);
$content =  str_replace($search, $replace, $file_tpl);
		

3.1.4. preg_replace

		
$a = '<br><a href="/calendar/app/cont_13522705.html" class="text">7月10日当周ECRI领先指标</a>';
echo preg_replace("(<a[^>]*class=\"text\">(.+?)<\/a>)","$1", $a);
		
		

3.1.5. 去掉字符串两端空白字符

包括回车换行等等控制字符

$username =  trim($username);
		





原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

目录
相关文章
|
Android开发
libx264.c:function X264_init: error: undefined reference to x264_encoder_open_142
libx264.c:function X264_init: error: undefined reference to x264_encoder_open_142
140 0
|
测试技术 Linux
linux c in common use function reference manual
End User License Agreement   guarantees or warranties,大战前得磨刀!!!!! Tips:C Funcs Chk header Modules! Characters of the test piece(on the street sta...
727 0
|
27天前
【Azure Durable Function】PowerShell Activity 函数遇见 Newtonsoft.Json.JsonReaderException: The reader's MaxDepth of 64 has been exceeded.
【Azure Durable Function】PowerShell Activity 函数遇见 Newtonsoft.Json.JsonReaderException: The reader's MaxDepth of 64 has been exceeded.
|
27天前
|
安全 JavaScript 应用服务中间件
【Azure Function App】如何修改Azure函数应用的默认页面呢?
【Azure Function App】如何修改Azure函数应用的默认页面呢?
|
27天前
|
C# C++ Python
【Azure 应用服务】Azure Durable Function(持久函数)在执行Activity Function时候,因为调用函数名称错误而导致长时间无响应问题
【Azure 应用服务】Azure Durable Function(持久函数)在执行Activity Function时候,因为调用函数名称错误而导致长时间无响应问题
|
27天前
|
SQL JavaScript 前端开发
【Azure 应用服务】Azure JS Function 异步方法中执行SQL查询后,Callback函数中日志无法输出问题
【Azure 应用服务】Azure JS Function 异步方法中执行SQL查询后,Callback函数中日志无法输出问题
|
27天前
|
JSON 数据格式 Python
【Azure 应用服务】Azure Function Python函数中,如何获取Event Hub Trigger的消息Event所属于的PartitionID呢?
【Azure 应用服务】Azure Function Python函数中,如何获取Event Hub Trigger的消息Event所属于的PartitionID呢?
|
27天前
|
C++ Python
【Azure 应用服务】Azure Function Python函数部署到Azure后遇见 Value cannot be null. (Parameter 'receiverConnectionString') 错误
【Azure 应用服务】Azure Function Python函数部署到Azure后遇见 Value cannot be null. (Parameter 'receiverConnectionString') 错误
|
27天前
【Azure 应用服务】Azure Function Timer触发函数加上Singleton后的问题
【Azure 应用服务】Azure Function Timer触发函数加上Singleton后的问题
|
27天前
|
消息中间件 Kafka 网络安全
【Azure 应用服务】本地创建Azure Function Kafka Trigger 函数和Kafka output的HTTP Trigger函数实验
【Azure 应用服务】本地创建Azure Function Kafka Trigger 函数和Kafka output的HTTP Trigger函数实验

热门文章

最新文章