<基础> PHP 字符串操作
explode — 使用一个字符串分割另一个字符串
array explode ( string $delimiter , string $string [, int $limit ] )
implode — 将一个一维数组的值转化为字符串
string implode ( string $glue , array $pieces )
htmlspecialchars — 将特殊字符转换为 HTML 实体 (XXS)
string htmlspecialchars ( string $string )
htmlspecialchars_decode — 将特殊的 HTML 实体转换回普通字符 (与 htmlspecialchars 相反)
string htmlspecialchars_decode ( string $string )
strip_tags — 从字符串中去除 HTML 和 PHP 标记(和htmlspecialchars不同的是 strip_tags 是直接去除标记,而前者是转义成另外的字符)
string strip_tags ( string $str [, string $allowable_tags ] )
md5 — 计算字符串的 MD5 散列值
string md5 ( string $str [, bool $raw_output = false ] )
nl2br — 在字符串所有新行之前插入 HTML 换行标记 (能将浏览器不能识别的 \n 或者 \r\n 转化成 </br>)
string nl2br ( string $string [, bool $is_xhtml = TRUE ] )
trim — 去除字符串首尾处的空白字符(或者其他字符)
string trim ( string $str [, string $character_mask = " \t\n\r\0\x0B" ] )
strpos — 查找字符串首次出现的位置(stripos 不区分大小写)(通常用于判断字符串中是否包含另一个字符串)
int stripos ( string $haystack , string $needle [, int $offset = 0 ] )
strrpos — 计算指定字符串在目标字符串中最后一次出现的位置
int strrpos ( string $haystack , string $needle [, int $offset = 0 ] )
strstr — 查找字符串的首次出现 返回第一次出现的位置开始到 haystack 结尾的字符串
string strstr ( string $haystack , mixed $needle [, bool $before_needle = FALSE ] )
strrchr — 查找指定字符在字符串中的最后一次出现
string strrchr ( string $haystack , mixed $needle )
strlen — 获取字符串长度(也可以用来判断字符串是否为空)
int strlen ( string $string )
strtolower — 将字符串转化为小写
string strtolower ( string $string )
strtoupper — 将字符串转化为大写
string strtoupper ( string $string )
substr_count — 计算字串出现的次数
int substr_count ( string $haystack , string $needle [, int $offset = 0 [, int $length ]] )
substr — 返回字符串的子串(返回字符串 string 由 start 和 lenth 参数指定的子字符串)
string substr ( string $string , int $start [, int $length ] )
str_replace — 子字符串替换(忽略大小写请用 str_ireplace)
mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )
search
查找的目标值,也就是 needle。一个数组可以指定多个目标。
replace
search 的替换值。一个数组可以被用来指定多重替换。
subject
执行替换的数组或者字符串。也就是 haystack。
如果 subject 是一个数组,替换操作将遍历整个 subject,返回值也将是一个数组。
count
如果被指定,它的值将被设置为替换发生的次数。
<基础> PHP 字符串操作的更多相关文章
- python学习笔记(字符串操作、字典操作、三级菜单实例)
字符串操作 name = "alex" print(name.capitalize()) #首字母大写 name = "my name is alex" pri ...
- shell编程常用的截取字符串操作
1. 常用的字符串操作 1.1. 替换字符串:$ echo ${var/ /_}#支持正怎表达式 / /表示搜索到第一个替换,// /表示搜索到的结果全部替换. ...
- php字符串操作集锦
web操作, 主要就是对字符文本信息进行处理, 所以, 字符串操作几乎占了很大一部分的php操作.包括 注意strstr 和 strtr的区别? 前者表示字符串查找返回字符串,后者表示字符串中字符替换 ...
- java 字符串操作和日期操作
一.字符串操作 创建字符串 String s2 = new String("Hello World"); String s1 = "Hello World"; ...
- [No000078]Python3 字符串操作
#!/usr/bin/env python3 # -*- coding: utf-8 -*- '''Python 字符串操作 string替换.删除.截取.复制.连接.比较.查找.包含.大小写转换.分 ...
- Python 字符串操作及string模块使用
python的字符串操作通过2部分的方法函数基本上就可以解决所有的字符串操作需求: python的字符串属性函数 python的string模块 1.字符串属性方法操作: 1.>字符串格式输出对 ...
- C语言字符串操作总结大全
1)字符串操作 strcpy(p, p1) 复制字符串 函数原型strncpy(p, p1, n) 复制指定长度字符串 函数原型strcat(p, p1) 附加字符串 函数原型strn ...
- c# 字符串操作
一.字符串操作 //字符串转数组 string mystring="this is a string" char[] mychars=mystring.ToCharArray(); ...
- C语言字符串操作总结大全(超详细)
本篇文章是对C语言字符串操作进行了详细的总结分析,需要的朋友参考下 1)字符串操作 strcpy(p, p1) 复制字符串 strncpy(p, p1, n) 复制指定长度字符串 strcat( ...
- JavaScript中常见的字符串操作函数及用法
JavaScript中常见的字符串操作函数及用法 最近几次参加前端实习生招聘的笔试,发现很多笔试题都会考到字符串的处理,比方说去哪儿网笔试题.淘宝的笔试题等.如果你经常参加笔试或者也是一个过来人,相信 ...
随机推荐
- 迭代器和增强for
增强for 内部原理其实是个Iterator迭代器,所以在遍历的过程中,不能对集合中的元素进行增删操作. 格式: for(元素的数据类型 变量 : Collection集合or数组){ } 它用于遍 ...
- 峰Redis学习(2)Jedis 入门实例
参考博客:http://blog.java1234.com/blog/articles/314.html 第一节:使用Jedis 连接Redis 新建maven项目: pom.xml: <pro ...
- 切换了webview 定位不了的解决方法 (还没有试,记录在此)
# 切换到 webview time.sleep(2) print(driver.contexts) driver.switch_to.context('WEBVIEW_com.tencent.mm: ...
- file /usr/lib64/mysql/plugin/dialog.so from install of Percona-Server-server-56-5.6.24-rel72.2.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.60-1.el7_5.x86_64
!!!点下面!!! https://www.cnblogs.com/chuijingjing/p/10005922.html
- 廖雪峰Java2-2数据封装-2构造方法
在2-2-1中,创建1个实例需要3步 Person ming = new Person(); ming.setName(" 小明 "); ming.setAge(16); 问题:能 ...
- 跨域验证cookie与缓存控制
1. 是否能跨域完全取决于浏览器控制,浏览器可以直接拒绝发送跨域请求(服务器根本收不到),也可以发送给服务器等接收到返回信息后决定是否让它被读取. 2. 服务器并不能辨别请求是从哪个源发过来的,只有在 ...
- svn在commit后报错:is scheduled for addition, but is missing
删除文件夹后点commit提交,但是报错,报错内容如下: 提示 "svn: Commit failed (details follow): svn: '/***/xxx.c' is sche ...
- CSS实现鼠标悬浮无限向下级展示的简单代码
*{ margin:; padding:; } ul,li{ list-style: none; } .ui-slide-box{ width: 300px; } .ui-slide-item{ wi ...
- OOP学习
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Python多进程vs多线程
多任务的两种方式:多进程和多线程. 如果用多进程实现Master-Worker,主进程就是Master,其他进程就是Worker. 如果用多线程实现Master-Worker,主线程就是Master, ...