|
@@ 5377-5392 (lines=16) @@
|
| 5374 |
|
* |
| 5375 |
|
* @return string|false The portion of haystack or false if needle is not found. |
| 5376 |
|
*/ |
| 5377 |
|
public static function strrchr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false) |
| 5378 |
|
{ |
| 5379 |
|
if ($encoding !== 'UTF-8') { |
| 5380 |
|
$encoding = self::normalize_encoding($encoding, 'UTF-8'); |
| 5381 |
|
} |
| 5382 |
|
|
| 5383 |
|
if ($cleanUtf8 === true) { |
| 5384 |
|
// "\mb_strpos" and "\iconv_strpos" returns wrong position, |
| 5385 |
|
// if invalid characters are found in $haystack before $needle |
| 5386 |
|
$needle = self::clean($needle); |
| 5387 |
|
$haystack = self::clean($haystack); |
| 5388 |
|
} |
| 5389 |
|
|
| 5390 |
|
// fallback to "mb_"-function via polyfill |
| 5391 |
|
return \mb_strrchr($haystack, $needle, $before_needle, $encoding); |
| 5392 |
|
} |
| 5393 |
|
|
| 5394 |
|
/** |
| 5395 |
|
* Reverses characters order in the string. |
|
@@ 5435-5449 (lines=15) @@
|
| 5432 |
|
* |
| 5433 |
|
* @return string|false <p>The portion of haystack or<br />false if needle is not found.</p> |
| 5434 |
|
*/ |
| 5435 |
|
public static function strrichr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false) |
| 5436 |
|
{ |
| 5437 |
|
if ($encoding !== 'UTF-8') { |
| 5438 |
|
$encoding = self::normalize_encoding($encoding, 'UTF-8'); |
| 5439 |
|
} |
| 5440 |
|
|
| 5441 |
|
if ($cleanUtf8 === true) { |
| 5442 |
|
// "\mb_strpos" and "\iconv_strpos" returns wrong position, |
| 5443 |
|
// if invalid characters are found in $haystack before $needle |
| 5444 |
|
$needle = self::clean($needle); |
| 5445 |
|
$haystack = self::clean($haystack); |
| 5446 |
|
} |
| 5447 |
|
|
| 5448 |
|
return \mb_strrichr($haystack, $needle, $before_needle, $encoding); |
| 5449 |
|
} |
| 5450 |
|
|
| 5451 |
|
/** |
| 5452 |
|
* Find position of last occurrence of a case-insensitive string. |