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开始 转义字符字符串的格式化输出切片常用函 ...
随机推荐
- Jquery鼠标滚动到页面底部自动加载更多内容,使用分页
index.php代码 [html] view plaincopy <!DOCTYPE html PUBLIC ;} .single_item{padding: ...
- phpcmsv9 幻灯片管理模块_UTF8
幻灯片管理模块简介: .可创建多个位置,一个网站多个幻灯处调用互不影响. .独立模块,不修改系统内核,不用担心升级问题. .标签调用灵活. 安装: .复制本目录下面的phpcms目录到你的V9根目录下 ...
- python logging用法
import logging logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(filename)s[line:%(line ...
- Objective-C专题,是学习iOS开发的前奏(转)
第一个OC的类 来源:http://www.cnblogs.com/mjios/archive/2013/04/06/3002814.html 本文目录 一.语法简介 二.用Xcode创建第一个OC的 ...
- nodeAPI--FS
fs是唯一一个同时提供同步和异步API的模块: 读取文件夹文件名,数组形式返回: var fs = require('fs'); //async fs.readdir('./',function(er ...
- Hadoop_10_shuffle02_详解Shuffle过程【来源网络】推荐更为详细
网址:http://www.cnblogs.com/felixzh/p/4680808.html Shuffle过程,也称Copy阶段.reduce task从各个map task上远程拷贝一片数据, ...
- .NET 4.0中的泛型的协变和逆变
转自:http://www.cnblogs.com/jingzhongliumei/archive/2012/07/02/2573149.html 先做点准备工作,定义两个类:Animal类和其子类D ...
- 找规律 SGU 107 987654321 problem
题目地址:http://acm.sgu.ru/problem.php?contest=0&problem=107 /* 题意:n位数的平方的后面几位为987654321的个数 尼玛,我看描述这 ...
- POJ1845 Sumdiv(求所有因数和+矩阵快速幂)
题目问$A^B$的所有因数和. 根据唯一分解定理将A进行因式分解可得:A = p1^a1 * p2^a2 * p3^a3 * pn^an.A^B=p1^(a1*B)*p2^(a2*B)*...*pn^ ...
- LightOJ1201 A Perfect Murder(树形DP)
一道经典的树型DP入门题.dp[u][0/1]表示u点不选或选时以u为根的子树最多能选择的点数. 题目给的有向有环图可以看作森林,注意不是树,因为题目没有说图是连通的! #include<cst ...