PHP Salt


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

Version: 2.20.2
Last Build: October 16, 2017 12:40pm (PST)

Main Menu

Home

Get PHP Salt


The Functions

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

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