|
@@ 5473-5488 (lines=16) @@
|
| 5470 |
|
* |
| 5471 |
|
* @return string|false The portion of haystack or false if needle is not found. |
| 5472 |
|
*/ |
| 5473 |
|
public static function strrchr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false) |
| 5474 |
|
{ |
| 5475 |
|
if ($encoding !== 'UTF-8') { |
| 5476 |
|
$encoding = self::normalize_encoding($encoding, 'UTF-8'); |
| 5477 |
|
} |
| 5478 |
|
|
| 5479 |
|
if ($cleanUtf8 === true) { |
| 5480 |
|
// "\mb_strpos" and "\iconv_strpos" returns wrong position, |
| 5481 |
|
// if invalid characters are found in $haystack before $needle |
| 5482 |
|
$needle = self::clean($needle); |
| 5483 |
|
$haystack = self::clean($haystack); |
| 5484 |
|
} |
| 5485 |
|
|
| 5486 |
|
// fallback to "mb_"-function via polyfill |
| 5487 |
|
return \mb_strrchr($haystack, $needle, $before_needle, $encoding); |
| 5488 |
|
} |
| 5489 |
|
|
| 5490 |
|
/** |
| 5491 |
|
* Reverses characters order in the string. |
|
@@ 5531-5545 (lines=15) @@
|
| 5528 |
|
* |
| 5529 |
|
* @return string|false <p>The portion of haystack or<br />false if needle is not found.</p> |
| 5530 |
|
*/ |
| 5531 |
|
public static function strrichr($haystack, $needle, $before_needle = false, $encoding = 'UTF-8', $cleanUtf8 = false) |
| 5532 |
|
{ |
| 5533 |
|
if ($encoding !== 'UTF-8') { |
| 5534 |
|
$encoding = self::normalize_encoding($encoding, 'UTF-8'); |
| 5535 |
|
} |
| 5536 |
|
|
| 5537 |
|
if ($cleanUtf8 === true) { |
| 5538 |
|
// "\mb_strpos" and "\iconv_strpos" returns wrong position, |
| 5539 |
|
// if invalid characters are found in $haystack before $needle |
| 5540 |
|
$needle = self::clean($needle); |
| 5541 |
|
$haystack = self::clean($haystack); |
| 5542 |
|
} |
| 5543 |
|
|
| 5544 |
|
return \mb_strrichr($haystack, $needle, $before_needle, $encoding); |
| 5545 |
|
} |
| 5546 |
|
|
| 5547 |
|
/** |
| 5548 |
|
* Find position of last occurrence of a case-insensitive string. |