Reply to Re: Which array function?

Your name:

Reply:


Posted by Tim Martin on 09/11/06 08:18

deko wrote:
> I have a file containing only UNIX timestamps that I pull into an array
> with file($myarray)
>
> I need to get a count of timestamps that fall between specific times -
> those that are less than 24-hours old, those that are between 24-hours
> old and 30-days old, and so forth.
>
> I thought about using array_filter and a function like this:
>
> function getlast24h($visits24h)
> {
> return ($visits24h > TIMEAGO24H);
> }
>
> $last24h_array = array_filter($myarray, "getlast24h");
>
> where TIMEAGO24H is a constant representing a timestamp of time() - 24hours
>
> but then I cannot get any additional time segments (such as last 30days,
> last 3 months, etc) - since $myarray will have had those timestamps
> filtered out.

array_filter() doesn't modify its argument, since it is passed by value
not reference. Therefore $myarray won't have the timestamps removed, and
can be used again.

Tim

[Back to original 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

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