Is there a function in PHP that returns true if a string/int could be safely converted into an int? like so:
var_dump(f('1'));//returns true
var_dump(f(1));//returns true
var_dump(f('1.2'));//returns false
var_dump(f(-2));//returns true
var_dump(f('3x'));//returns false
I do not care about bases.
I checked out is_int, but is_int('4') returns false.
I could use a cast/intval, but:
intval('6x') returns 6, and intval('x') returns 0 as does intval(0) and intval('0')
function f ($i) { return "$i" === "".(int)$i; }