Received: from optimus.prime (adsl-dynamic-1-406C4898.kalamazoo.mi.ameritech.net [64.108.72.152]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f3QFoq313859 for ; Thu, 26 Apr 2001 11:50:52 -0400 (EDT) (envelope-from marshall@pacdemon.org) Received: from pacdemon.org (IDENT:marshall@localhost [127.0.0.1]) by optimus.prime (8.11.0/8.11.0) with ESMTP id f3QFoe902619; Thu, 26 Apr 2001 11:50:46 -0400 Message-ID: <3AE843D0.AF0C8010@pacdemon.org> Date: Thu, 26 Apr 2001 11:50:40 -0400 From: Wesley Leonard Organization: PacDemon X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.4.3 i586) X-Accept-Language: en MIME-Version: 1.0 To: imago CC: pgsql-php@postgresql.org Subject: Re: data type casting to numbers with intval() or doubleval() References: <00cf01c0b307$02ac4080$543987cf@corp.peoplesoft.com> <09fd01c0ce65$ccd14760$e875f718@imago> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200104/34 X-Sequence-Number: 287 I think a regex would be most appropriate here: This removes all letters and takes the int value. In perl you can remove everything that's NOT a digit but I didn't figure that out in PHP yet... this should do for now. l8er imago wrote: > > I am having a problem with the intval() function > > I am using it to take string data and extract the number it would > represent if only numeric. > > $my_integer = intval($my_string) > > when the sting is numbers followed by letters - > $my_string = 4444mmm > $my_integer = 4444 > it works as expected > > but when letters are followed by numbers > $my_string = mmm4444 > $my_integer = 0 > > Same problem with doubleval() > > What am I missing???? how do I drop the non-numeric parts of a > string? > > imago -- Wesley Leonard marshall@pacdemon.org http://www.pacdemon.org "...I want Linux to be on the cutting edge, and even a bit past the edge, because what's past the edge today is what's on your desktop tomorrow." --Linus Torvalds