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
psStrBeginsWithi()
Determine if a string begins with a specific substring


Description:

You can use this to find out if a string begins with something specific.




Usage:

$bool = psStrBeginsWith($needle,$haystack);
$bool = psStrBeginsWithi($needle,$haystack); // case insensitive



Example:


if ( psStrBeginsWith("PR_","PR_TEST") == true )
{
// do something
}





Code:


function psStrBeginsWith($needle,$haystack)
{
$res = false;
$l = strlen($needle);
if (substr($haystack,0,$l) == $needle)
{
$res = true;
}

return $res;
}

function psStrBeginsWithi($needle,$haystack)
{
$res = false;
$l = strlen($needle);
if (substr(strtolower($haystack),0,$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