|
@@ 5041-5056 (lines=16) @@
|
| 5038 |
|
* |
| 5039 |
|
* @return string|false The portion of haystack or false if needle is not found. |
| 5040 |
|
*/ |
| 5041 |
|
public static function strrchr(string $haystack, string $needle, bool $before_needle = false, string $encoding = 'UTF-8', bool $cleanUtf8 = false) |
| 5042 |
|
{ |
| 5043 |
|
if ($encoding !== 'UTF-8' && $encoding !== 'CP850') { |
| 5044 |
|
$encoding = self::normalize_encoding($encoding, 'UTF-8'); |
| 5045 |
|
} |
| 5046 |
|
|
| 5047 |
|
if ($cleanUtf8 === true) { |
| 5048 |
|
// "\mb_strpos" and "\iconv_strpos" returns wrong position, |
| 5049 |
|
// if invalid characters are found in $haystack before $needle |
| 5050 |
|
$needle = self::clean($needle); |
| 5051 |
|
$haystack = self::clean($haystack); |
| 5052 |
|
} |
| 5053 |
|
|
| 5054 |
|
// fallback to "mb_"-function via polyfill |
| 5055 |
|
return \mb_strrchr($haystack, $needle, $before_needle, $encoding); |
| 5056 |
|
} |
| 5057 |
|
|
| 5058 |
|
/** |
| 5059 |
|
* Reverses characters order in the string. |
|
@@ 5097-5111 (lines=15) @@
|
| 5094 |
|
* |
| 5095 |
|
* @return string|false <p>The portion of haystack or<br>false if needle is not found.</p> |
| 5096 |
|
*/ |
| 5097 |
|
public static function strrichr(string $haystack, string $needle, bool $before_needle = false, string $encoding = 'UTF-8', bool $cleanUtf8 = false) |
| 5098 |
|
{ |
| 5099 |
|
if ($encoding !== 'UTF-8' && $encoding !== 'CP850') { |
| 5100 |
|
$encoding = self::normalize_encoding($encoding, 'UTF-8'); |
| 5101 |
|
} |
| 5102 |
|
|
| 5103 |
|
if ($cleanUtf8 === true) { |
| 5104 |
|
// "\mb_strpos" and "\iconv_strpos" returns wrong position, |
| 5105 |
|
// if invalid characters are found in $haystack before $needle |
| 5106 |
|
$needle = self::clean($needle); |
| 5107 |
|
$haystack = self::clean($haystack); |
| 5108 |
|
} |
| 5109 |
|
|
| 5110 |
|
return \mb_strrichr($haystack, $needle, $before_needle, $encoding); |
| 5111 |
|
} |
| 5112 |
|
|
| 5113 |
|
/** |
| 5114 |
|
* Find position of last occurrence of a case-insensitive string. |