When I fetch data from a database, the result is a string even if it has an number value. Here's what I mean:
// An integer
$int=10;
if(is_int($int)) // Returns true
...
// A string
$int='10';
if(is_int($int)) // Returns false
...
I want both of these to return true.
Use is_numeric()
if you want it to accept floating point values, and ctype_digit()
for integers only.
You're looking for is_numeric().
http://php.net/is_numeric
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With