Filed under: Useful PHP Functions | Tags: email validation, email validation in php, php email validate, php email validation, validate email
Validate your email address by regular expression in PHP. Tiny but useful function and easy to extend.
function EmailAddressValidator($Email)
{
if(eregi(“^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$”, $Email))
return true;
else
return false;
}
Filed under: Useful PHP Functions | Tags: full string, php string function, return full words, return string php
This function will return you substring of any number of characters without broken last word. Very useful function and easy to extend as you need.
function StringWithFullWords($MainString,$NoOrCharecter=10)
{
$Tmp=str_split($MainString,1);
for($I=0;$I$NoOrCharecter)
break;
if($Tmp[$I]==” “)
$LastSpacePos=$I;
}
return substr($MainString,0,$LastSpacePos);
}
Filed under: Useful PHP Functions | Tags: common functions, custom function, frequently used functions, php functions, Useful Functions PHP, wide used functions
The following function is able to display a file whether it’s flash or image. Short but useful function and easy to customize.
function ShowPictureOrFlash($ImageName,$ImagePath,$ImageSize,$ImageBorder=0,$ImgBorderColor=”")
{
$ImageNameWithPath=$ImagePath.$ImageName;
if (file_exists($ImageNameWithPath))
{
$ImageHeightWidth = GetImageSize($ImageNameWithPath);
$Height = $ImageHeightWidth[1];
$Width = $ImageHeightWidth[0];
if($Width>$ImageSize)
{
$multiplier=$ImageSize/$Width;
$Width = $Width*$multiplier;
$Height = $Height*$multiplier;
}
$IsItFlash=substr($ImageNameWithPath,-3,3);
if($IsItFlash==”swf”)
{
echo “”
.”"
.”"
.”"
.”"
.”";
}
else
echo ““;
}
}