php字符串常用函数
addslashes
print addslahes ('She said, "Great!"');
#output
#She said, \"Great!\
echo
echo "hello world"
#output
#hello world
explode/implode
#explode
$var = 'Learn PHP';
print_r (explode (' ',$var));
# Result:
# Array ( [0] => Learn [1] => PHP )
#implode
$array1 = array('one','two','three');
print (implode ('+',$array1));
# output
# one+two+three
htmlentities
print htmlentities('<br>An example');
# output
# <br>An example
htmlspecialchars
print htmlspecialchars('Is "this" true? 3 > 2', ENT_NOQUOTES);
# output
# Is "this" true? 3 > 2
md5
print md5('1');
# Result:
# c4ca4238a0b923820dcc509a6f75849b
number_format
number_format (number, [number_of_decimals], [decimal_character], [thousand_separator_character])
print number_format(5432.105, 3, ',', '.');
# Result:
# 5.432,105
str_replace
str_replace ('match_pattern', 'replacement_pattern', 'text', [count])
print str_replace ('str','k','The string replacement function in PHP is str_replace');
#Result:
#The king replacement function in PHP is k_replace
strlen
print strlen('strlen function');
#output
#15
strstr
strstr ('string', 'match_pattern', [before_indicator])
print strstr("PHP strstr function", 'str'); #output 'strstr function'
print strstr("php strstr function", 'str',TRUE) #output 'PHP' [before_indicator]该参数自 php 5.3.0引入
substr
substr ('string', position_start, substr_length)
print substr('PHP substr is a substring function', 5, 3); #output 'ubs'
参考
http://www.1keydata.com/php-tutorial/string-functions.php
http://developer.51cto.com/art/200807/94916.htm
php字符串常用函数的更多相关文章
- Excel怎样从一串字符中的某个指定“字符”前后截取字符及截取字符串常用函数
怎么样可以从一串字符中的某个指定位置的前或后截取指定个数的字符. 如:12345.6789,我要截取小数点前(或后)的3个字符.怎么样操作, 另外,怎么样从右边截取字符,就是和left()函数相反的那 ...
- python的基本用法(三)字符串常用函数
字符串常用函数 # s='.abcd.'# new_s=s.strip('.')#默认去掉字符串两边的空格和换行符,想去掉什么括号中就写什么# print('s',s)# print('new_s', ...
- python字符串 常用函数 格式化字符串 字符串替换 制表符 换行符 删除空白 国际货币格式
# 字符串常用函数# 转大写print('bmw'.upper()) # BMW# 转小写print('BMW'.lower()) # bmw# 首字母大写print('how aae you ?'. ...
- SQL Server中截取字符串常用函数
SQL Server 中截取字符串常用的函数: .LEFT ( character_expression , integer_expression ) 函数说明:LEFT ( '源字符串' , '要截 ...
- C 字符/字符串常用函数
string.h中常用函数 char * strchr(char * str ,char ch); 从字符串str中查找首次出现字符ch的位置,若存在返回查找后的地址,若不存在则返回NULL void ...
- golang字符串常用函数
package utils import "fmt" import "strconv" import "strings" var str s ...
- python面试题(二)字符串常用函数
今天在微信的公众号上看到了一遍python学习开发的文章,里面有一些python的面试题,碰巧最近python不知道学什么了,索性学一下这篇文章啊!!先写一下一些字符串的常用函数.(ps:本人太菜,若 ...
- Python 字符串常用函数
操作字符串的常用函数 函数 描述(返回值) str.capitalize() 将字符串的第一个字符大写 str.title() 返回标题化的字符串,即每个单词的首字母都大写 str.upper() 全 ...
- php 字符串常用函数
数组.字符串和数据库是我们函数里面最.最.最常用的三类函数. 当然PHP的字符串函数也有很多.我们最常使用的两个系列的字符串: 1.单字节字符串处理函数 2.多字节字符串处理函数 3.字符串编码转换函 ...
- Python—字符串常用函数
Python-字符串常用字符串 字符串是一种表示文本的数据类型,使用单引号和双引号及三引号表示 访问字符串中的值字符串的每个字符都对应一个下标,下标编号是从0开始 转义字符字符串的格式化输出切片常用函 ...
随机推荐
- Python语言开发的一些问题
1.Python是如何进行内存管理的? Python引用了一个内存池(memory pool)机制,即Pymalloc机制(malloc:n.分配内存),用于管理对小块内存的申请和释放内存池(memo ...
- vagrant,流浪汉,我又来啦。
最近学个DEVOPS2.0,讲微服务,容器华,持续部署,很到位,就一个一个工具撸一撸... vagrant,以前接触过,所以上手快,,哈哈,,用时再具体配置. virtualbox的. 基本命令: # ...
- Java Hour 32 Weather ( 5 ) struts2 – Action class
有句名言,叫做10000小时成为某一个领域的专家.姑且不辩论这句话是否正确,让我们到达10000小时的时候再回头来看吧. Hour 32 Struts2 Action 1 将action 映射到 ac ...
- String.split使用竖线做为分隔符
String.split使用竖线做为分隔符时会发现得到的数组不对,每个字符都被拆分成数组里的一个值: 解决办法:竖线需要转义才可以作为split的参数,String.split("\\|&q ...
- uva 10972(边双连通分量)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=33804. 思路:和poj的一道题有点像,不过这道题图可能不连通,因 ...
- C#学习笔记(三)——流程控制
一.布尔逻辑 1.与布尔有关的2元运算符 2.布尔运算符 PS:“&”与“&&“之类的区别 (1)”&“是按位运算,也就是说是将2个数都转换成2进制,然后逐个进行与操作 ...
- org.apache.log4j与org.apache.commons.logging这两个包有什么区别
apache common logging是一种log的框架接口,它本身并不实现log记录的功能,而是在运行时动态查找目前存在的日志库,调用相关的日志函数,从而隐藏具体的日志实现log4j是具体的日志 ...
- Android 贝塞尔曲线 折线图
1.贝塞尔曲线:http://baike.baidu.com/view/60154.htm,在这里理解什么是贝塞尔曲线 2.直接上图: 3.100多行代码就可以画出贝塞尔曲线,直接上代码 packag ...
- HTML-Canvas02
文字对齐方式 : 水平对齐 //是用 textAlign 属性设置水平对齐方式(默认坐标点) ctx.textAlign = "start"; ctx.font = "3 ...
- haohantechsoft-PDA软件,PDA管理软件,PDA管理系统,仓库PDA销售开单盘点软件
为了更好服务于广大服装客户群体进行销售.盘点.调拨配送等.推出基于无线网络版移动PDA销售开单盘点软件系统.该系统支持无线3G.WIFI.GPRS系统,用户可以手持PDA在无线网络连接状态下进行销售. ...