-
10月17日
-
【函数功能】
该函数查找指定字符串在另一字符串中第一次出现的位置(不区分大小写,若区分大小写请查看strpos()函数)。
【函数语法】
stripos ($haystack, $needle, $offset = null)
【参数说明】
$haystack:必需,要搜索的字符串。 $needle:必需。要查找的字符。 $offset:可选,开始搜索的位置。
【演示程序】
<?php /** * stripos ($haystack, $needle, $offset = null) * **/ $haystack = "Hello i am PHP!大家好,我是PHP!"; echo stripos($haystack, "l"); echo '<br>'; echo stripos($haystack, "好"); echo '<br>'; echo stripos($haystack, "l",3); ?>
【输出结果】
2 21 3
【特别注意】
1.该函数是不区分大小写的。 2.该函数是二进制安全的。 3.字符串位置从 0 开始,不是从 1 开始。 4.PHP 版本:5+。
【原版定义】
/** * Find the position of the first occurrence of a case-insensitive substring in a string * @link http://www.php.net/manual/en/function.stripos.php * @param haystack string <p> * The string to search in. * </p> * @param needle string <p> * Note that the needle may be a string of one or * more characters. * </p> * <p> * If needle is not a string, it is converted to * an integer and applied as the ordinal value of a character. * </p> * @param offset int[optional] <p> * If specified, search will start this number of characters counted from * the beginning of the string. Unlike strrpos and * strripos, the offset cannot be negative. * </p> * @return int the position of where the needle exists relative to the beginnning of * the haystack string (independent of offset). * Also note that string positions start at 0, and not 1. * </p> * <p> * Returns false if the needle was not found. */
转载请注明出处:php1234.cn ,原文地址:http://www.php1234.cn/a/functions/2016/1017/95.html
收藏文章

登录
表情删除后不可恢复,是否删除
取消
确定
图片正在上传,请稍后...
取消上传
评论内容为空!
还没有评论,快来抢沙发吧!
畅言云评
站长点击我去广告>
热评话题
- PHP数组其他类函数array_walk_recursive_PHP1234|PHP修炼之路|跟着明礼馨德一起修炼PHP
- 礼者,人之所履,夙兴夜寐,以成人伦之序_PHP1234|PHP修炼之路|跟着明礼馨德一起修炼PHP
- PHP Variable函数之判断变量函数之is_real_PHP1234|PHP修炼之路|跟着明礼馨德一起修炼PHP
- 德者,人之所得,使万物各得其所欲_PHP1234|PHP修炼之路|跟着明礼馨德一起修炼PHP
- 义者,人之所宜,赏善罚恶,以立功立事_PHP1234|PHP修炼之路|跟着明礼馨德一起修炼PHP
- 夫欲为人之本,不可无一焉_PHP1234|PHP修炼之路|跟着明礼馨德一起修炼PHP
- 仁者,人之所亲,有慈惠恻隐之心,以遂其生成_PHP1234|PHP修炼之路|跟着明礼馨德一起修炼PHP