RE: [PHP] String -> Number Automatic Conversion

From: Date: Thu, 03 Feb 2005 18:07:23 +0000
Subject: RE: [PHP] String -> Number Automatic Conversion
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-208017@lists.php.net to get a copy of this message
Nuzzo Art-CINT116 wrote: >> Possible work-around: >> I suspect that >> $p1[14] = "-0.15" + 0; >> will do what you want, since the leading 0 will probably >> trigger the regex properly. >> >> Try it and see. > > Changing it to -0.15 + 0 works. This data is actually coming from a > numeric field in an Oracle database using the OCI interface so I am not > sure why it's a string instead of a number but that's a separate issue I > need to look into. I'm not certain about OCI or others, but generally PHP database extensions retrieve all data as text... At least, the last time I checked on that, that's what it was... Could be wrong or out of date. Rarely worry about data type in PHP, once you understand the type juggling and conversion rules. -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#208017) next »