Sometimes we need to calculate the percentage of certain value in our project. In that circumstances you can use following PHP snippet to do that task.echo get_percentage(10, 100); //usage function get_percentage($percentage, $of) { //courtesy : http://stackoverflow.com/a/14880194 $percent = $percentage / $of; return number_format( $percent * 100, 2 ) . '%';; }
It is really annoying to know that half of your users’ emails getting bounced because these sneaky users used some disposable email address to register on your site. Yes, it happens a lot, the only way to stop this from happening again is to block them from ever using those phony emails again.
Sometimes you need to extract domain name from email using PHP for whatever reason, in that case you can use code below :$email = "[email protected]"; $domain_name = substr(strrchr($email, "@"), 1); echo "Domain name is :" . $domain_name;
Sometimes we need to create a widget in WordPress Template, to create a new widget just drop this line in your theme function.php file, and make changes as required.