Monday, October 22, 2012

PHP Function to check whether the given number is decimal or not.

Below is a simple Function to check whether the given number is decimal or not.



function check_decimal($dec_val, $decimals = 2)
{
                        $pattern = "/^[-]*[0-9][0-9]*\.[0-9]{".$decimals."}$/";
                        if (preg_match($pattern,  $dec_val))
                                    return true;
                        else
                                    return false;
}

No comments:

Post a Comment

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation...