@@ 5765-5780 (lines=16) @@ | ||
5762 | * |
|
5763 | * @return string|false The portion of haystack or false if needle is not found. |
|
5764 | */ |
|
5765 | public static function strrchr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false) |
|
5766 | { |
|
5767 | if ($encoding !== 'UTF-8') { |
|
5768 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
|
5769 | } |
|
5770 | ||
5771 | if ($cleanUtf8 === true) { |
|
5772 | // "\mb_strpos" and "\iconv_strpos" returns wrong position, |
|
5773 | // if invalid characters are found in $haystack before $needle |
|
5774 | $needle = self::clean($needle); |
|
5775 | $haystack = self::clean($haystack); |
|
5776 | } |
|
5777 | ||
5778 | // fallback to "mb_"-function via polyfill |
|
5779 | return \mb_strrchr($haystack, $needle, $before_needle, $encoding); |
|
5780 | } |
|
5781 | ||
5782 | /** |
|
5783 | * Reverses characters order in the string. |
|
@@ 5823-5837 (lines=15) @@ | ||
5820 | * |
|
5821 | * @return string|false <p>The portion of haystack or<br>false if needle is not found.</p> |
|
5822 | */ |
|
5823 | public static function strrichr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false) |
|
5824 | { |
|
5825 | if ($encoding !== 'UTF-8') { |
|
5826 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
|
5827 | } |
|
5828 | ||
5829 | if ($cleanUtf8 === true) { |
|
5830 | // "\mb_strpos" and "\iconv_strpos" returns wrong position, |
|
5831 | // if invalid characters are found in $haystack before $needle |
|
5832 | $needle = self::clean($needle); |
|
5833 | $haystack = self::clean($haystack); |
|
5834 | } |
|
5835 | ||
5836 | return \mb_strrichr($haystack, $needle, $before_needle, $encoding); |
|
5837 | } |
|
5838 | ||
5839 | /** |
|
5840 | * Find position of last occurrence of a case-insensitive string. |