Re: String valid?

From: Date: Mon, 21 Apr 2003 06:25:06 +0000
Subject: Re: String valid?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-144608@lists.php.net to get a copy of this message
oops. that '.' shouldn't be in the or list Sorry, -Dan Anderson On Mon, 2003-04-21 at 02:24, Daniel R. Anderson wrote: > You could try something like this: > > function is_string_a_number($string) > { > $fff = fopen('temp','w'); // I'm sorry but I like I/O .. :-P > fwrite($fff,$string); > fclose($fff); > $fff = fopen('temp','r'); > while ($fff and (!(feof($fff)))) > { > $a_char = fgetc($fff); > if (!(($a_char == '1') or ($a_char == '2') or ($a_char == > '3') or > ($a_char == '4') or ($a_char == '5') or ($a_char == > '6') or > ($a_char == '7') or ($a_char == '8') or ($a_char == > '9') or > ($a_char == '0') or ($a_char == '.'))) > { > return FALSE; > } > }; > return TRUE; > } > > I'm a relative noob to PHP, and would love it if anybody can offer any > tips or advice as to why this code is good or bad. :-) > > -Dan Anderson >

« previous php.general (#144608) next »