|
Posted by deko on 09/07/06 09:58
> The number_format() function accepts the given number as a float, but
> you're passing a string as the number. What happens if you rather do
> the last 2 lines like this?
>
> $i = number_format(floatval($var[0]));
> $k = number_format(floatval($var[1]));
That sounds like a good idea and I will implement your suggestion. Thanks.
But I think the problem I was having was caused by contention for that file.
Apparently, another process had a lock on it and file($myfile) was not returning
anything. So I tried this:
$timeout = 0;
$gotlock = false;
$fp = fopen($data_file, "r");
while ($timeout < 10 && $gotlock === false)
{
if (flock($fp, LOCK_EX))
{
$mydata = fread($fp, filesize($data_file));
flock($fp, LOCK_UN);
$gotlock = true;
}
else
{
usleep(100000);
}
$timeout++;
}
if ($gotlock)
{
[process data]
}
seems to be working....
Navigation:
[Reply to this message]
|