psStrEndsWithi() Determine if a string ends with a specific substring
Description:
You can use this to find out if a string ends with something specific.
Usage:
$bool = psStrEndsWith($needle,$haystack); $bool = psStrEndsWithi($needle,$haystack); // case insensitive
Example:
if ( psStrEndsWith(".jpg","duck.jpg") == true ) { // do something }
Code:
function psStrEndsWith($needle,$haystack) { $res = false; $l = strlen($needle) * -1; if (substr($haystack,$l) == $needle) { $res = true; }
return $res; }
function psStrEndsWithi($needle,$haystack) { $res = false; $l = strlen($needle) * -1; if (substr(strtolower($haystack),$l) == strtolower($needle)) { $res = true; }
return $res; }
Changlelog:
|
|