You are here: Re: How to explode array from file? « PHP Programming Language « IT news, forums, messages
Re: How to explode array from file?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация