PHP Salt


A little dash of PHP... my collection of php functions

Version: 2.33.2
Last Build: December 29, 2023 20:28pm (PST)

Main Menu

Home

Get PHP Salt


The Functions

array
db
file
graph
html
mail
math
misc
mobile
script
string
system
time
web
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:


And a shot out to:

PHP - php.net
Fedora Server - getfedora.com
Shameless ads to pay for site