Re: var type

From: Date: Mon, 18 Dec 2000 19:31:23 +0000
Subject: Re: var type
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-30895@lists.php.net to get a copy of this message
Hi Thomas!!! make a cast... try this <?php $a = "111"; $b = "21"; if( (int)$a > (int)$b ) { print "A"; } else { print "B"; } ?> Hope it helps you! regards Marcelo Gulin Thomas Holton escribió: > Hello, > I have strings that contain numbers... this is because it is easier to > insert chars into strings of numbers for prettier displays. However, now > that i want to compare these strings NUMERICALLY, i cannot. > IOW: > string1 = "2001"; > string2 = "2002"; > > if( string2 >= string1 ) { ... > > but this is never true, as it should be. How can i integerize these > strings for simple numerical comparison. > > thanks > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#30895) next »