Re: problem with intval and !=

From: Date: Thu, 23 Oct 2003 15:54:41 +0000
Subject: Re: problem with intval and !=
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-167304@lists.php.net to get a copy of this message
On Thu, 2003-10-23 at 11:51, Robert Cummings wrote: > On Thu, 2003-10-23 at 11:21, Cesar Cordovez wrote: > > > > At this point, I think I have to change the procedure. This is not > > good. Any sugestions on how to now if the user types an integer number > > in a field? > > > > Here's a really simple way: > > if( ereg( '^[[:space:]]*[[:digit:]]+[[:space:]]*', $input ) ) > { > // Yaaaaaaay, integer input! > } Whoops, forgot the trailing $ if( ereg( '^[[:space:]]*[[:digit:]]+[[:space:]]*$', $input ) ) { // Yaaaaaaay, integer input! } Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

« previous php.general (#167304) next »