I have a field that people enter the hard drive size and I want the number stored in a float field. If they enter '40.0 GB' that obviously will not work, so how do I strip off everything but integeres and decimals first?
Thanks for the help.
StupidScript
4:56 pm on May 26, 2005 (gmt 0)
floatval([mixed string]);
Like:
$thisvar="40.0 GB";
$clean=floatval($thisvar);
echo $clean;
Note that float'ing 40.0 results in 40. Float'ing 40.1 results in 40.1. Also, it doesn't matter whether there is a space in the string or not ... as long as it begins with the numeric value.
RussellC
5:04 pm on May 26, 2005 (gmt 0)
Sweet. I knew there was something easy but I couldn't find it on the php site. Thanks!