RE: [PHP] Adding 1 to a whole number
| From: | Don Read | Date: | Sat, 30 Jun 2001 18:00:57 +0000 |
| Subject: | RE: [PHP] Adding 1 to a whole number | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-55675@lists.php.net to get a copy of this message | ||
On 30-Jun-01 Richard Kurth wrote:
> Way is this doing this Starting with 1000 all I what to do is increse
> this number by one the first time I run it it adds 1 to the number 10001
> second time it 10001002
> Shouldn't it just add 1 to the number 1000,1001,1002,1003
>
strings don't add well, give a hint to php to use integers:
>
> $data = fgets($fp2, 1000);
>
> $data1 = $data + "1";
>
> fwrite($fp2,$data1);
>
> echo $data1;
Strings don't add nearly as well as numbers, give a hint to php
to use integers; & reset your file pointer.
$data = 1 + $data;
rewind($fp);
fwrite($fp, "$data");
Regards,
--
Don Read dread@texas.net
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.