X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FStrings.php;h=2f27e4a5ff9b1cbb91f358bf7b64a572123e0d49;hb=24f8ee8e676abf4dd16916fd417562aca7bcbb9f;hp=35e7ebe1510c732ccd793e2837297acdbbf666b0;hpb=ad47ff50a95bc482e741fdaed2f1aeea297635be;p=friendica.git diff --git a/src/Util/Strings.php b/src/Util/Strings.php index 35e7ebe151..2f27e4a5ff 100644 --- a/src/Util/Strings.php +++ b/src/Util/Strings.php @@ -1,6 +1,6 @@ debug_backtrace()]); return $s; } @@ -379,6 +380,7 @@ class Strings /** * Check if the first string starts with the second * + * @see http://maettig.com/code/php/php-performance-benchmarks.php#startswith * @param string $string * @param string $start * @return bool @@ -390,6 +392,21 @@ class Strings return $return; } + /** + * Checks if the first string ends with the second + * + * @see http://maettig.com/code/php/php-performance-benchmarks.php#endswith + * @param string $string + * @param string $end + * @return bool + */ + public static function endsWith(string $string, string $end) + { + $return = substr_compare($string, $end, -strlen($end)) === 0; + + return $return; + } + /** * Returns the regular expression string to match URLs in a given text *