PHP搜索字符串函数 strstr()

| | Comments (2)



定义和用法

strstr() 函数搜索一个字符串在另一个字符串中的第一次出现。

该函数返回字符串的其余部分(从匹配点)。如果未找到所搜索的字符串,则返回 false。

语法

strstr(string,search)
参数 描述
string 必需。规定被搜索的字符串。
search 必需。规定所搜索的字符串。如果该参数是数字,则搜索匹配数字 ASCII 值的字符

提示和注释

注释:该函数是二进制安全的。

注释:该函数对大小写敏感。如需进行大小写不敏感的搜索,请使用 PHP stristr() 函数。

例子

例子 1

<?php
echo strstr("Hello world!","world");
?>

输出:

world!

例子 2

在本例中,我们将搜索 "o" 的 ASCII 值所代表的字符:

<?php
echo strstr("Hello world!",111);
?>

输出:

o world!

2 Comments

你好 需要你的帮忙 能给个Q么

有问题请留言,slashlu[at]gmail.com

Leave a comment

Archives

Ads by google

Pages

Powered by Movable Type 4.24-en

About this Entry

This page contains a single entry by 单点日志 published on August 26, 2011 11:30 PM.

垃圾站大爱:dedecms织梦采集侠 was the previous entry in this blog.

dedecms arclistsg typeid 栏目ID实现调用动态参数 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.