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

Difference between strstr() and stristr() functions in PHP.

Both functions are used to return or finds the first occurence of a substring from a string, and give all string from first occurence to end of string except than stristr() is case-insensitive.
If no match is found then FALSE will be returned.

$email = '';
$host = strstr($email, '@');
echo $host;

stristr() does the same thing in Case-insensitive manner

How to Find Quarter Month From Any Year ?

A Quarter means 1/4 part of year.
In the following example given Script is
use to find which quarter of the year
in the given date.

Assuming given date is 10 December 2015
Following is the Example.
Just Copy & Paste and Enjoy.

$month = 12;
$date = 10;
$year = 2015;
$qm = mktime(0,0,0,$month,$date,$year);
echo ceil(date("m", $qm)/3);

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;
return true;

How to share your page or website ?

<!-- AddToAny BEGIN -->
<a href="">Share</a>
<span class="a2a_divider"></span>
<a class="a2a_button_twitter"></a>
<a class="a2a_button_f<acebook"></a>
<script type="text/javascript">
var a2a_config = a2a_config || {};
a2a_config.linkurl = "your url here";
<script type="text/javascript" src=""></script>
<!-- AddToAny END -->

Validate URL in PHP

To validate url at server side use this function.
In this function $variable defines the your string which you want to validate.

$reg_exp = /(http?://)?([da-z.-]+).([a-z.]{2,6})([/w ?=.-]*)*/?$/