Detect leap year

Detect leap year for gregorian and shamsi date.

function gLeapYear($year)
    if (($year % 4 == 0) and (($year % 100 != 0) or ($year % 400 == 0)))
        return true;
        return false;
function sLeapYear($year)
    $ary = array(1, 5, 9, 13, 17, 22, 26, 30);
    $b = $year % 33;
    if (in_array($b, $ary))
        return true;
    return false;
echo sLeapYear(1392).' ';
echo gLeapYear(2013);


No tag here.

Recommended pages

Delete or Remove all files and folders in a directory‎...

If you want to delete everything from folder (including subfolders) use this function. function removeDir( $dir ) { if ( is_dir( $dir ) ) { $objects = scandir( $dir ); foreach ( $o...

Encrypt and Decrypt function with different outputs...

Encrypt function return different value with each execute but decrypt function return input value. for example: first execute: encrypt('hello') => 'axxdfg34', decrypt('axxdfg34') return 'hello'...

Detect file extension function...

This function is used to find the file extension also you can use pathinfo() function for get information about a file path. function ext($file_name) { return substr($file_name, strrpos($fi...

Email Address Checker...

This function check if an e-mail address is valid or not. function valid_email($email) { return preg_match('/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/', $email);...