Sorry if I'm missing something, there's a lot of replies after my first
post on this thread.
Is there something wrong with the floor() approach? I liked the regex
solution but isn't it more expensive and more verbose than just doing a
well commented is_numeric plus floor/ceil math?
Just trying
On 16-3-2013 19:20, Matijn Woudt wrote:
On Sat, Mar 16, 2013 at 6:52 PM, Maciek Sokolewicz
maciek.sokolew...@gmail.com wrote:
Hi,
I have tried to find a way to check if a character string is possible to
test whether it is convertible to an intger !
any suggestion ?
BR georg
All
On Sun, Mar 17, 2013 at 10:20 PM, Maciek Sokolewicz
maciek.sokolew...@gmail.com wrote:
On 16-3-2013 19:20, Matijn Woudt wrote:
On Sat, Mar 16, 2013 at 6:52 PM, Maciek Sokolewicz
maciek.sokolew...@gmail.com wrote:
Hi,
I have tried to find a way to check if a character string is
On Fri, Mar 15, 2013 at 8:34 PM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:
On Thu, Mar 14, 2013 at 7:02 PM,
georggeorg.chamb...@telia.com**
I have tried to find a way to check if a character string is
possible to
test whether it is convertible to an intger !
The op wasn't about
On Fri, 2013-03-15 at 22:32 -0400, Andrew Ballard wrote:
Guess regex are the only useful solution here. When you consider to use
built-in functions, just remember, that for example '0xAF' is an integer
too, but '42.00' isn't.
Shoot...I hadn't considered how PHP might handle hex or octal
On Mar 16, 2013 6:14 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
On Fri, 2013-03-15 at 22:32 -0400, Andrew Ballard wrote:
Guess regex are the only useful solution here. When you consider to use
built-in functions, just remember, that for example '0xAF' is an
integer
too, but
On Sat, 2013-03-16 at 11:46 -0400, Andrew Ballard wrote:
On Mar 16, 2013 6:14 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
On Fri, 2013-03-15 at 22:32 -0400, Andrew Ballard wrote:
Guess regex are the only useful solution here. When you consider to use
built-in functions, just
Hi,
I have tried to find a way to check if a character string is possible to
test whether it is convertible to an intger !
any suggestion ?
BR georg
All responses in this thread have been very nice; but you could also try
a much simpler 2-step check:
1. is_numeric
2. if true check if
On Sat, Mar 16, 2013 at 6:52 PM, Maciek Sokolewicz
maciek.sokolew...@gmail.com wrote:
Hi,
I have tried to find a way to check if a character string is possible to
test whether it is convertible to an intger !
any suggestion ?
BR georg
All responses in this thread have been very nice;
On Sat, Mar 16, 2013 at 12:21 PM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:
On Sat, 2013-03-16 at 11:46 -0400, Andrew Ballard wrote:
On Mar 16, 2013 6:14 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
On Fri, 2013-03-15 at 22:32 -0400, Andrew Ballard wrote:
Guess regex
On 3/14/2013 4:05 PM, Matijn Woudt wrote:
On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote:
On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote:
Something like if (is_numeric($var) $var == floor($var)) will do the
trick. I don't know if there's a better (more elegant)
On 15/03/13 06:21, Jim Lucas wrote:
On 3/14/2013 4:05 PM, Matijn Woudt wrote:
On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote:
On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote:
Something like if (is_numeric($var) $var == floor($var)) will do
the
trick. I don't know if
On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote:
On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford p...@justcroft.com wrote:
On 15/03/13 06:21, Jim Lucas wrote:
On 3/14/2013 4:05 PM, Matijn Woudt wrote:
On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote:
On
On 15/03/2013 22:00, Ashley Sheridan wrote:
On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote:
For my money, `is_numeric()` does just what I want.
The thing is, is_numeric() will not check if a string is a valid int,
but any valid number, including a float.
For something like
On 03/15/2013 02:33 PM, richard gray wrote:
On 15/03/2013 22:00, Ashley Sheridan wrote:
On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote:
For my money, `is_numeric()` does just what I want.
The thing is, is_numeric() will not check if a string is a valid int,
but any valid
On Fri, Mar 15, 2013 at 4:00 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:
**
On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote:
On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford p...@justcroft.com wrote:
On 15/03/13 06:21, Jim Lucas wrote:
On 3/14/2013 4:05 PM, Matijn
tamouse mailing lists tamouse.li...@gmail.com wrote:
On Fri, Mar 15, 2013 at 4:00 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:
**
On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote:
On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford p...@justcroft.com
wrote:
On 15/03/13
I suppose one could try something like this:
if (is_string($val) $val === (string)(int)$val)
If $val is an integer masquerading as a string, it should be identical to
the original string when cast back to a string, shouldn't it? (I can't try
it right now.)
Andrew
2013/3/16 Ashley Sheridan a...@ashleysheridan.co.uk
tamouse mailing lists tamouse.li...@gmail.com wrote:
On Fri, Mar 15, 2013 at 4:00 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:
**
On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote:
On Fri, Mar 15, 2013 at 3:55
2013/3/16 Andrew Ballard aball...@gmail.com
I suppose one could try something like this:
if (is_string($val) $val === (string)(int)$val)
If $val is an integer masquerading as a string, it should be identical to
the original string when cast back to a string, shouldn't it? (I can't try
On Mar 15, 2013 9:54 PM, Sebastian Krebs krebs@gmail.com wrote:
2013/3/16 Andrew Ballard aball...@gmail.com
I suppose one could try something like this:
if (is_string($val) $val === (string)(int)$val)
If $val is an integer masquerading as a string, it should be identical to
the
Guess regex are the only useful solution here. When you consider to use
built-in functions, just remember, that for example '0xAF' is an integer
too, but '42.00' isn't.
Shoot...I hadn't considered how PHP might handle hex or octal strings when
casting to int. (Again, not in front of a computer
On Sat, Mar 16, 2013 at 2:54 AM, Sebastian Krebs krebs@gmail.comwrote:
2013/3/16 Andrew Ballard aball...@gmail.com
I suppose one could try something like this:
if (is_string($val) $val === (string)(int)$val)
If $val is an integer masquerading as a string, it should be
Hi,
I have tried to find a way to check if a character string is possible to test
whether it is convertible to an intger !
any suggestion ?
BR georg
On Thu, Mar 14, 2013 at 7:02 PM, georg georg.chamb...@telia.com wrote:
Hi,
I have tried to find a way to check if a character string is possible to
test whether it is convertible to an intger !
any suggestion ?
BR georg
You could use is_numeric for that, though it also accepts floats.
Something like if (is_numeric($var) $var == floor($var)) will do the
trick. I don't know if there's a better (more elegant) way.
On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudt tijn...@gmail.com wrote:
On Thu, Mar 14, 2013 at 7:02 PM, georg georg.chamb...@telia.com wrote:
Hi,
I have
On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote:
Something like if (is_numeric($var) $var == floor($var)) will do the
trick. I don't know if there's a better (more elegant) way.
On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudttijn...@gmail.com wrote:
On Thu, Mar 14, 2013 at 7:02 PM,
On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote:
On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote:
Something like if (is_numeric($var) $var == floor($var)) will do the
trick. I don't know if there's a better (more elegant) way.
On Thu, Mar 14, 2013 at 3:09 PM,
28 matches
Mail list logo