mb_strrichr
大小写不敏感地查找指定字符在另一个字符串中最后一次的出现
PHP 4.0.6 及以上版本
mb_strrichr 函数用于查找字符串中最后一次出现指定字符的当前位置(从右侧开始搜索),并返回该位置的字符串部分。
mb_strrichr(string $str, string $char): string
返回从字符 char 在字符串 str 中最后一次出现位置起的所有字符组成的子字符串。如果没有找到该字符,返回 FALSE。
<?php $str = "hello world, hello php"; $char = "o"; $result = mb_strrichr($str, $char); echo $result; // 输出 "o, hello php" ?>
在该示例中,mb_strrichr 查找字符串 "hello world, hello php" 中最后一次出现字符 "o" 的位置,并返回从该位置开始的所有字符。因此,返回值为 "o, hello php"。