Do you know of a function that can check if a string contains an integer?
Here\'s how I\'d expect it to work:
holds_int(\"23\") // should return true
I liked nyson's suggestion, but noticed that it will be false for '0123'. I'm now doing this:
(string)(int)$var === ltrim((string)$var, '0')
(This would have been posted as a comment @nyson, but I don't have enough privileges to do that yet).
Edited to add: If you want zero to be true, you need to do something like
(int)$var === 0 || (string)(int)$var === ltrim((string)$var, '0')