Author Archives: Bhagwat Singh

Format Phone Numbers

function format_phone($phone) { $phone = preg_replace(“/[^0-9]/”, “”, $phone); if(strlen($phone) == 7) return preg_replace(“/([0-9]{3})([0-9]{4})/”, “$1-$2”, $phone); elseif(strlen($phone) == 10) return preg_replace(“/([0-9]{3})([0-9]{3})([0-9]{4})/”, “($1) $2-$3”, $phone); else return $phone; }

Comments Off on Format Phone Numbers

Checking if Database Table exists

To determine if the table exists. we need to do the following code. if($wpdb->get_var(“SHOW TABLES LIKE ‘$table_name’”) == $table_name) {//Table Exists} else {//Table Not Exists}

Comments Off on Checking if Database Table exists

Parent Page Refresh Through Javascript

There are many ways to refresh the parent page from the sub-window(modal window) through javascript. Some of them are: window.parent.document.location.reload(); parent.location.reload();

Comments Off on Parent Page Refresh Through Javascript

URL Validation In Javascript

function isUrl(url) { var RegexUrl = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; return RegexUrl.test(url); }

Comments Off on URL Validation In Javascript

Get Number In 2 Decimal Point.

function formatmoney($Value) { $Result = split(“[.]”, $Value); $Temp = substr($Result[1],0,2); $Temp1 = str_pad($Temp,2,”0″,STR_PAD_RIGHT); $FinalResult = $Result[0] .’.’.$Temp1; return $formatted = number_format($FinalResult, 2); }

Comments Off on Get Number In 2 Decimal Point.

Welcome To Portfolio of Web Developer

Greetings, and a sincerly welcome to Portfolio of Web Developer. My name is Bhagwat Singh and I’m a web-developer based in Rajasthan, INDIA. I have 9+ years Experience in Web Development using PHP. Throughout my site you’ll find information about … Continue reading

Tagged , | Comments Off on Welcome To Portfolio of Web Developer