From http://codegeekz.com/10-useful-handy-php-snippets-for-developers/