Tag Archives: PHP

empty() function PHP

empty() function determines whether given variable is empty and also used for checking variable is set or not. Variable is said to empty if it is not set or value is false. empty values can be : 0 “” or “0” 0.0 (0 float value) FALSE empty array() NULL Reference : http://php.net/manual/en/function.empty.php

How to Remove Characters Except Numbers from a String ?

Following Code will remove all character,special characters including space.   $givenNumber = "1245fdfd8454D FDFDF434 3$#$#%";   $testingNumber = preg_replace('[D]’, ”, $givenNumber);   echo $testingNumber;   Output is : 124584544343 $givenNumber = "1245fdfd8454D FDFDF434 3$#$#%"; $testingNumber = preg_replace(‘[D]’, ”, $givenNumber); echo $testingNumber; Output is : 124584544343

Validate Email in PHP

Use this function to validate email in PHP. Pass your email in this function by calling it.if  it returns false then email is not valid else valid. function checkEmail($email_address = null){ if(preg_match("/^[a-zA-Z]*w+(.w+)*@w+(.[0-9a-zA-Z]+)*.[a-zA-Z]{2,4}$/", $email_address) === 0){ return false; } else{ return true; } }function checkEmail($email_address = null){ if(preg_match("/^[a-zA-Z]*w+(.w+)*@w+(.[0-9a-zA-Z]+)*.[a-zA-Z]{2,4}$/", $email_address) === 0){ return false; } else{ return… Read More »