PHP使用strstr()函数获取指定字符串后所有字符的方法,strstr字符串
本文实例讲述了PHP使用strstr()函数获取指定字符串后所有字符的方法。分享给大家供大家参考,具体如下:
PHP的strstr()函数可搜索字符串在另一字符串中的第一次出现位置,并返回字符串的剩余部分。
strstr()函数定义如下:
strstr(string,search,before_search)
参数说明:
string 必需。规定被搜索的字符串。
search
必需。规定所搜索的字符串。
如果此参数是数字,则搜索匹配此数字对应的 ASCII 值的字符。
before_search
可选。默认值为 "false" 的布尔值。
如果设置为 "true",它将返回 search 参数第一次出现之前的字符串部分。
示例代码如下:
<?php echo strstr("欢迎来到帮客之家","脚本"); echo "<br/>"; echo strstr("Welcome To www.jb51.net","jb51"); echo "<br/>"; echo strstr("123456789","5"); ?>
运行结果如下:
帮客之家 jb51.net 56789
补充:
在PHP5.3版本之后才可使用strstr()函数的第三个可选参数,如:
echo strstr("123456789","5",true); //输出:1234
更多关于PHP字符串操作相关内容可查看本站专题:《php字符串(string)用法总结》
希望本文所述对大家PHP程序设计有所帮助。
您可能感兴趣的文章:
- PHP中substr_count()函数获取子字符串出现次数的方法
- PHP中strncmp()函数比较两个字符串前2个字符是否相等的方法
- PHP中strnatcmp()函数“自然排序算法”进行字符串比较用法分析(对比strcmp函数)
- PHP中strcmp()和strcasecmp()函数字符串比较用法分析
- PHP中substr函数字符串截取用法分析
- PHP使用trim函数去除字符串左右空格及特殊字符实例
- PHP封装的字符串加密解密函数
- 最准确的php截取字符串长度函数
- PHP中使用substr()截取字符串出现中文乱码问题该怎么办
- PHP常用字符串操作函数实例总结

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver Mac version
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment
