in reply to Re: Checking whether a $var is a number
in thread Checking whether a $var is a number

I think you have a typo in your substr which should be

substr($x,0,1);

Otherwise the case $x=0; falls into the not a number part of the if.