PHP strrpos strpos strstr strrchr 区别
1. strstr
string strstr ( string $haystack , mixed $needle [, bool $before_needle = false ] )
$needle 为字符串,如果不是字符串,那么转化为整型,使用该整型对应的字符。
返回 该字符(串)首次出现到字符串尾部分, 包括该字符(串)。
2. strrchr
string strrchr ( string $haystack , mixed $needle )
$needle为字符, 如果是字符串,使用字符串的首字符作为匹配字符(区别于其他几个函数对字符串情况的处理), 如果不是字符也不是字符串,则转化为整型,使用该整型对应的字符。
返回该字符最后一次出现到字符串尾部分, 包括该字符。
3. strpos
int strpos ( string $haystack , mixed $needle [, int $offset = 0 ] )
返回某个字符串第一次出现的位置, 如果 needle 不是一个字符串,那么它将被转换为整型并被视为字符的顺序值。
4. strrpos
返回某个字符最后一次出现的位置, 如果 needle 不是一个字符串,那么它将被转换为整型并被视为字符的顺序值。
<?php $str = 'sailrancho@qq.com'; echo strstr($str,'qq.'); // 返回 qq.com
echo "\n";
echo strrchr($str, 'ch'); // 返回 com 注意返回不是cho@qq.com
echo "\n";
echo strpos($str, 'c'); //返回 7
echo "\n";
echo strrpos($str, 'c'); // 返回14
PHP strrpos strpos strstr strrchr 区别的更多相关文章
- PHP stripos()、strripos()和strrpos() 使用方法和区别
区别 stripos():查找字符串首次出现的位置(不区分大小写) 写法:stripos ( string $haystack , string $needle [, int $offset = 0 ...
- php使用strpos,strstr,strchr注意啦,若是数字查找则会当成ASCII码处理
strpos,strstr,strchr都是查找某字符出现的位置,若未找到,则返回false(判断是===) 如: var_dump(strpos("oa",'97')); var ...
- php -- strpos,stripos,strrpos,strripos,strstr,strchr,stristr,strrchr
strpos() 函数 语法: mixed strpos ( string $haystack , mixed $needle [, int $offset = 0 ] ) 查找 needle 在 h ...
- PHP核心编程知识点
一.PHP基本语法 PHP标记:一共有四种,只推荐使用第一种 语句结束符:分号 注释:行注释(// #)和块注释(/* */),注释的规范 二.常见的输出语句 print echo var_du ...
- php中strstr、strrchr、substr、stristr四个函数的区别总结
php中strstr.strrchr.substr.stristr四个函数的区别总结 投稿:junjie 字体:[增加 减小] 类型:转载 时间:2014-09-22我要评论 这篇文章主要介绍了php ...
- php中strstr、strrchr、substr、stristr四个函数用法区别
php中strstr.strrchr.substr.stristr四个函数用法区别: php中strstr strrchr substr stristr这四个字符串操作函数特别让人容易混淆,常用的是s ...
- [PHP源码阅读]strpos、strstr和stripos、stristr函数
我在github有对PHP源码更详细的注解.感兴趣的可以围观一下,给个star.PHP5.4源码注解.可以通过commit记录查看已添加的注解. strpos mixed strpos ( strin ...
- php strpos() 函数介绍与使用方法详解
本文主要和大家介绍PHP中mb_strpos的使用技巧,通过使用语法以及实例给大家详细分析了用法,需要的朋友参考学习下.希望能帮助到大家.mb_strpos(PHP 4 >= 4.0.6, PH ...
- php字符串处理函数常见问题
PHP 的字符串处理功能非常强大,主要包括: 字符串输出 echo():输出一个或多个字符串 print():输出一个字符串 printf():输出格式化字符串 字符串去除 trim():去除字符串 ...
随机推荐
- hdu 2051
ps:这道题是题目坑爹了...题目说不考虑n=0的...但其实要考虑...醉了 中文意思:输入一个10进制的数,输出他的二进制数 代码: #include "stdio.h"int ...
- To and Fro
Description Mo and Larry have devised a way of encrypting messages. They first decide secretly on th ...
- web app 变革之rem
rem这是个低调的css单位,近一两年开始崭露头角,有许多同学对rem的评价不一,有的在尝试使用,有的在使用过程中遇到坑就弃用了.但是我对rem综合评价是用来做web app它绝对是最合适的人选之一. ...
- linux/lib/string.c
/** * strlen - Find the length of a string * @s: The string to be sized */ size_t strlen(const char ...
- 如何用cufflinks 拼出一个理想的注释文件
后记: cufflinks安装: 下载安装包, 不要下载source code ,直接下载binary. Source code Linux x86_64 binary http://cu ...
- DB2中的ROW_NUMBER() OVER()函数用法
ROW_NUMBER() OVER()大概有俩方面的作用 1,分页, 并返回分页结果集.2,是对数据进行处理 分组 db2的分页: select tmp.* from ( SELECT rownu ...
- poj 2299 树状数组求逆序对数+离散化
Ultra-QuickSort Time Limit: 7000MS Memory Limit: 65536K Total Submissions: 54883 Accepted: 20184 ...
- 用jquery ,当改变窗口或屏幕大小时调用function,用哪个事件?
$(window).resize(function(){ //process here}); window的onresize事件. $(window).resize(function () { ...
- jsp页面 date转化成string
1.先引入fmt标签<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> ...
- leetcode 105 Construct Binary Tree from Preorder and Inorder Traversal ----- java
Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that ...