首页 > Web开发 > 详细

php--某个字符在字符串中的位置比较

时间:2015-12-27 12:05:34      阅读:234      评论:0      收藏:0      [点我收藏+]
<?php


$haystack = ‘helloe‘;
$needle   = ‘e‘;

$pos      = stripos($haystack, $needle);

echo "\n";

echo $pos;die;  // 加r的是5 ,不加r的是 1,索引值从0开始,所以判断时 要 false !== $pos 来判断

/*

stripos

(PHP 5)
stripos — Find the position of the first occurrence of a case-insensitive substring in a string

strpos

(PHP 4, PHP 5)
strpos — Find the position of the first occurrence of a substring in a string

查看一个字符在字符串中首次出现的位置,i 表示忽略大小写

strripos

(PHP 5)
strripos — Find the position of the last occurrence of a case-insensitive substring in a string


strrpos

(PHP 4, PHP 5)
strrpos — Find the position of the last occurrence of a substring in a string

查看一个字符在字符串中最后一次出现的位置,i 表示忽略大小写

*/

  

php--某个字符在字符串中的位置比较

原文:http://www.cnblogs.com/lixiuran/p/5079645.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!