| @@ 3731-3742 (lines=12) @@ | ||
| 3728 | * |
|
| 3729 | * @return bool |
|
| 3730 | */ |
|
| 3731 | public static function str_ends_with(string $haystack, string $needle): bool |
|
| 3732 | { |
|
| 3733 | if (!isset($haystack[0], $needle[0])) { |
|
| 3734 | return false; |
|
| 3735 | } |
|
| 3736 | ||
| 3737 | if (\substr($haystack, -\strlen($needle)) === $needle) { |
|
| 3738 | return true; |
|
| 3739 | } |
|
| 3740 | ||
| 3741 | return false; |
|
| 3742 | } |
|
| 3743 | ||
| 3744 | /** |
|
| 3745 | * Check if the string ends with the given substring, case insensitive. |
|
| @@ 3752-3763 (lines=12) @@ | ||
| 3749 | * |
|
| 3750 | * @return bool |
|
| 3751 | */ |
|
| 3752 | public static function str_iends_with(string $haystack, string $needle): bool |
|
| 3753 | { |
|
| 3754 | if (!isset($haystack[0], $needle[0])) { |
|
| 3755 | return false; |
|
| 3756 | } |
|
| 3757 | ||
| 3758 | if (self::strcasecmp(\substr($haystack, -\strlen($needle)), $needle) === 0) { |
|
| 3759 | return true; |
|
| 3760 | } |
|
| 3761 | ||
| 3762 | return false; |
|
| 3763 | } |
|
| 3764 | ||
| 3765 | /** |
|
| 3766 | * Case-insensitive and UTF-8 safe version of <function>str_replace</function>. |
|
| @@ 3817-3828 (lines=12) @@ | ||
| 3814 | * |
|
| 3815 | * @return bool |
|
| 3816 | */ |
|
| 3817 | public static function str_istarts_with(string $haystack, string $needle): bool |
|
| 3818 | { |
|
| 3819 | if (!isset($haystack[0], $needle[0])) { |
|
| 3820 | return false; |
|
| 3821 | } |
|
| 3822 | ||
| 3823 | if (self::stripos($haystack, $needle) === 0) { |
|
| 3824 | return true; |
|
| 3825 | } |
|
| 3826 | ||
| 3827 | return false; |
|
| 3828 | } |
|
| 3829 | ||
| 3830 | /** |
|
| 3831 | * Limit the number of characters in a string, but also after the next word. |
|
| @@ 4100-4111 (lines=12) @@ | ||
| 4097 | * |
|
| 4098 | * @return bool |
|
| 4099 | */ |
|
| 4100 | public static function str_starts_with(string $haystack, string $needle): bool |
|
| 4101 | { |
|
| 4102 | if (!isset($haystack[0], $needle[0])) { |
|
| 4103 | return false; |
|
| 4104 | } |
|
| 4105 | ||
| 4106 | if (\strpos($haystack, $needle) === 0) { |
|
| 4107 | return true; |
|
| 4108 | } |
|
| 4109 | ||
| 4110 | return false; |
|
| 4111 | } |
|
| 4112 | ||
| 4113 | /** |
|
| 4114 | * Get a binary representation of a specific string. |
|