Re: Re: how do i get a variable type? - not that simple

From: Date: Sun, 18 Mar 2001 21:34:13 +0000
Subject: Re: Re: how do i get a variable type? - not that simple
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-7584@lists.php.net to get a copy of this message
You could use ereg/preg to determine whether it: a) consists of nothing but digits from beginning to end, example: ^[0-9]+$ b) consists of nothing but digits separated by a single decimal, example: ^[0-9]+[.][0-9]+$ c) doesn't match the first two conditions, and therefore assume it is a string. In article <9938lh$e5k$1@toye.p.sourceforge.net>, info@graphicon.nu ("phpman") wrote: > i can't though, the variable and its value comes out of a string .. like > this.. > > $var_string = > "var1=this_is_a_value|var2=4.5|var3=another_value|var4=3.1415"; > > then i extract the pairs of vars and vals, then I need to determine if val > is string or integer. > > > ----- Original Message ----- > From: "Michael Geier" <mgeier@cdmsports.com> > To: "phpman" <info@graphicon.nu> > Sent: Sunday, March 18, 2001 2:37 PM > Subject: RE: [PHP] how do i get a variable type? - not that simple > > > > anything wrapped in quotes is a string... > > > > try: > > > > $a=3; > > echo(gettype($a)); > > > > -----Original Message----- > > From: phpman [mailto:info@graphicon.nu] > > Sent: Sunday, March 18, 2001 12:44 PM > > To: php-general@lists.php.net > > Subject: [PHP] how do i get a variable type? - not that simple > > > > > > No guys. that doesn't work. Take this code for example... > > > > $a="3"; > > echo(gettype($a)); > > > > this returns string > > i need to find it as an integer or real or float for the sql. which by the > > way is MySQL. > > > > thank you for responding, but I already know that gettype and all the > other > > is_* don't work for this. -- CC

« previous php.db (#7584) next »