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开始 转义字符字符串的格式化输出切片常用函 ...
随机推荐
- Maven使用笔记(七)Maven使用问题记录
1.Java-maven异常-cannot be cast to javax.servlet.Filter 报错 tomcat 启动后先将tomcat/lib目录下的jar包全部读入内存,如果weba ...
- Git自动部署
Git自动部署文件位于repository下面的hooks里的post-receive #!/bin/sh set -e git-update-server-info gitosis-run-hook ...
- 怎么在手机上查看sqlite db
在 从 百度应用 下载“SQLite编辑器(SQLite Editor)” 安装到手机上.前体是 手机已经Root(可以用360一键Root软件进行root).
- ODTwithODAC认识与安装图解
ODTwithODAC认识 ODTwithODAC是用.Net 开发工具时,使用Oracle数据库时, 启连接作用. 安装完ODTwithODAC之后,一般需要安装 Oracle 客户端(比如win3 ...
- Windows Server 2008 R2遗忘管理员密码后的解决方案
在日常的工作中,对于一个网络管理员来讲最悲哀的事情莫过于在没有备用管理员账户和密码恢复盘的情况下遗忘了本地管理员账户密码. 在早期的系统中,遇到这种事情可以使用目前国内的很多Windows PE光盘来 ...
- CDH中,如果管理CM中没有的属性
在CM配置管理中的"hive-site.xml 的 Hive 客户端高级配置代码段(安全阀)""仅适用于高级使用,逐个将字符串插入 hive-site.xml 的客户端配 ...
- 贪心 Codeforces Round #300 A Cutting Banner
题目传送门 /* 贪心水题:首先,最少的个数为n最大的一位数字mx,因为需要用1累加得到mx, 接下来mx次循环,若是0,输出0:若是1,输出1,s[j]--: 注意:之前的0的要忽略 */ #inc ...
- SQL Server跨库复制表数据错误的解决办法
SQL Server跨库复制表数据的解决办法 跨库复制表数据,有很多种方法,最常见的是写程序来批量导入数据了,但是这种方法并不是最优方法,今天就用到了一个很犀利的方法,可以完美在 Sql Serv ...
- Google Code Jam 2009 Qualification Round Problem C. Welcome to Code Jam
本题的 Large dataset 本人尚未解决. https://code.google.com/codejam/contest/90101/dashboard#s=p2 Problem So yo ...
- Hibernate使用MyExclipse10自动生成配置文件报错
使用MyExclipse10自动生成hibernate映射文件如下: 结果发现启动服务时报以下错误: 原因:因为hibernate换过项目地址,所以dtd文件的地址也换掉了.在hbm.xml文件里面把 ...