Hey,
I'm trying to determine if the characters in a string really should be a floatI have this code so far
but it doesn't work. For testing, $val is '1.63'. It being changed to an integer with this codePHP Code:if ( strstr($val, '.') && is_numeric(trim($val, '.')) ) {
settype($val, 'float');
}
and then I assume since that prunes out the decimal, it's not being picked up by the float checker.PHP Code:if ( is_numeric($val) ) {
settype($val, INT);
}
Any idea to fix this? I'm going to try putting the float checking code first and see if that makes a difference.
Thanks![]()



I have this code so far



Bookmarks