<?php
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);// Note our use of ===. Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
if ($pos === false) {
echo "The string '$findme' was not found in the string '$mystring'";
} else {
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
}// We can search for the character, ignoring anything before the offset
$newstring = 'abcdef abcdef';
$pos = strpos($newstring, 'a', 1); // $pos = 7, not 0
?>
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);// Note our use of ===. Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
if ($pos === false) {
echo "The string '$findme' was not found in the string '$mystring'";
} else {
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
}// We can search for the character, ignoring anything before the offset
$newstring = 'abcdef abcdef';
$pos = strpos($newstring, 'a', 1); // $pos = 7, not 0
?>
解决方案 »
- 一个JS删除option值问题
- 火狐无法获取图片宽度和高度的问题
- 网站备案:网站没有开通,也可以备案吗?
- cookie如何验证登录?有何问题?
- 关于windows xp下的配置问题??????????????
- php+ajax查询几十万条域名的mx记录然后去数据库比对执行增删改查的操作!
- (求助,讨论)区分国内和国外访问的方法
- 是不是我的配置有问题?为什么逻辑与(&&)不起作用?
- 怎么注册的SESSION变里,还可以这样用!是不是不安全!
- 我找不到办法解决!谢谢帮忙!
- 也是,看了半天文档测试,英文的调试老是不行,希望高手给个具体例子,不甚感谢,学习中!!!
- 请教一个关于下拉菜单的问题,知道的帮忙看看,谢谢!
后者与前者的功能,返回值都一样,只是不区分大小写。strstr("母字符串", "子字符串")用来查找子字符串在母字符串中第一次出现的位置,
并返回母字符串中从子字符串开始到母字符串结束的部分。
如果找不到子字符串,则返回空。