Posted on November 12, 2009 by Atif
Filed Under PHP

A while ago I was experimenting on how long does it take for a plain page to load on my local server. The output I was receiving was so small that it was being displayed in exponential form rather than decimal something like this 2.8848648071289E-5.
Well, to be honest I hate numbers with exponents because they are so confusing and secondly because they look ugly.
A quick Google for converting exponents to decimal didn’t work out for me, so I started out writing my own function using regular expressions except for the information that PHP automatically converts numbers with high precision into exponential form. “Strings!” was the first thing that flicked my mind reading that ad the second was “Regular Expressions”
So I made my own function to convert exponential into decimal, and the good thing is.. it works. Here is the trick
$total_time = 2.8848648071289E-5;
echo exp2dec($total_time);
function exp2dec($number) {
preg_match('/(.*)E-(.*)/', str_replace(".", "", $number), $matches);
$num = "0.";
while ($matches[2] > 0) {
$num .= "0";
$matches[2]--;
}
return $num . $matches[1];
}
Posted on November 08, 2009 by Atif
Filed Under Web Hosting
Hostgator one of the top web hosts in the market has come up with a new coupon this season. You can now avail the first month free on any shared package you sign up with hostgator or upto $25 of in case you want to buy for more than a month of hosting.
Here is how to get the deal
- Follow the link to the Hostgator Shared Hosting packages
- You will receive your welcome email in 15 minutes!
- Select your package, I would recommend the Baby plan which offers Unlimited of everything and $50 adwords credit (please note that you need to be from USA or Canada to avail this credit)
- Click on “I will use My Existing Domain and update My Nameservers only.” and pick your existing domain. If you create a new domain you will be charged for it separately.
- Now as a option choose “Monthly @ $8.95″
In a Coupon section write “cactus”
- Click “Next”
- Fill in all information. Don’t worry you will not be charged.
- As a Payment Option choose PayPal and Agree with a Terms and Condition of Use.
- Click on “Verify My Order”
- Complete Order

In my last post you have seen how to detect Internet Explorer 6 using Javascript. If you love jQuery like I do then here is the simple snippet that you can use to Internet Explorer 6 using jQuery.
jQuery.each(jQuery.browser, function(i, val) {
if(i=="msie" && jQuery.browser.version.substr(0,1)=="6")
alert("Do stuff for IE 6")
});
As a Web Developer I have stopped giving support to clients for Internet Explorer 6. Recently I was analysing the traffic on my social networking website (for those who don’t know I recently launched a social networking website exclusive for people in Hyderabad, its Wakaao!) and to my surprise about 30% of people visiting my social networking website are are still use the old is(not) gold Internet Explorer 6. I guess this can be either because
- They are using a public PC which as the first version of Windows XP
- Or Inadequate Computer knowledge to upgrade or install other browsers
- Or Are lazy and probably not intamated about the buggy and insecure web browser.
What ever the case may be, the problem is that my website has 1-2 rendering issues with IE6. Though I use a separate stylesheet for IE6 but I want to end up dealing with this IE6. Working with IE6 is a huge burden. So I wanted a simple jQuery powered modal box to pop up and tell them if they are using IE 6.
This is a simple function that can help you get the version of your browser. It returns the browser version for Internet Explorer and for others it returns -1.
function vIE() {
// returns version for IE or -1 for other browsers
return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;
}
Thanks to Marc Palau who commented this at The Future of Web
You can also detect Internet Explorer using jQuery