Re: Why don't ...
| From: | Rasmus Lerdorf | Date: | Sun, 16 Dec 2001 18:59:16 +0000 |
| Subject: | Re: Why don't ... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-77877@lists.php.net to get a copy of this message | ||
Is your second character perhaps a 0? That while loop is going to end as
soon as it gets a character that evaluates to 0. Write it like this
instead:
while(!feof($this->m_file)) {
$c = fgetc($this->m_file);
if(is_numeric($c)) $str .= $c;
}
-Rasmus
On Sun, 16 Dec 2001, Yoel Benitez Fonseca wrote:
> Hi!
>
> The following code fragment tries to read a sequence of digits from
> a file but it doesn't work, only the first character is read,
> Which is my error?.
>
>
> $str = "";
> while( ($c = fgetc($this->m_file)) && ereg("[0-9]", $c) ){
> $str .= $c;
> }
>
>
> Thank you in advance
>
>