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