for those of us who don't have PHP 5 >= 5.2.0 ::
function get_last_occurance($needle,$haystack){
$chunk = explode($needle,$haystack);
foreach ($chunk as $bit) $last_occurance = $bit;
return $last_occurance;
}
mb_strrichr
(PHP 5 >= 5.2.0)
mb_strrichr — 大小写不敏感地查找指定字符在另一个字符串中最后一次的出现
说明
string mb_strrichr
( string
$haystack
, string $needle
[, bool $part = false
[, string $encoding
]] )
mb_strrichr() 大小写不敏感地查找指定 needle 在 haystack 中最后一次的出现,并返回 haystack 的一部分。
和 mb_strrchr() 不同的是, mb_strrichr() 是大小写不敏感的。
如果 needle 没有找到,它将返回 FALSE。
参数
-
haystack -
在该字符串中查找
needle的最后出现位置 -
needle -
在
needle中查找该字符串 -
part -
决定这个函数返回
haystack的哪一部分。 如果设置为TRUE,它将返回的字符是从haystack的开始到needle最后出现的位置。 如果设置为FALSE,它将返回的字符是从needle最后出现的位置到haystack的末尾。 -
encoding -
使用的字符编码名称。如果省略了,则将使用内部编码。
返回值
返回 haystack 的一部分。
或者在没有找到 needle 时返回 FALSE。
code at seanmacdonald dot ca ¶
4 years ago
