Re: Wierd ass code...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




----- Original Message ----- From: "Ryan A" <genphp@xxxxxxxxx>
To: "php php" <php-general@xxxxxxxxxxxxx>
Sent: Saturday, May 13, 2006 9:20 PM
Subject:  Wierd ass code...


Hey,
Been reading some other code that I got from the net,
and  have come across some wierd looking code, would
appreciate it if someone could explain it to me:

$hits = array();
$bytes = array();
$blocked = array();
$baps = array();
$bapm = array();

So far so good.... then further down:

// Add to the running totals
@$hits["$username|$subnet"]++;
@$bytes["$username|$subnet"]+=$byte;
@$baps["$username|$subnet|$this_second"]++;
@$bapm["$username|$subnet|$this_minute"]++;

What kind of arrays are the above? I have never seen
nor worked with arrays like them before.

If you can point me to a particular place in the
manual or a few URLs too would be appreciated.

Thanks,
Ryan

I don't think there is nothing special with the arrays, he is just coding some information into strings, with the vertical bar as separator, and using this as the keys to several arrays where he is collecting some statistical information, such as (it would seem to me)
- number of hits by user and subnet
- number of bytes by user and subnet
- number of hits per user and subnet per second
- number of hits per user and subnet per  minute

I would assume that the variables $this_second and $this_minute are absolute numbers counted from a particular time, not seconds from 0 to 60 within the minute. Likewise for the minutes.

I assume that the @ in front is to avoid the error of trying to increment a value that is not yet set.

I guess that this same thing could have been achieved with multidimensional arrays but either concatenating the variables into a single string is faster or some other reason that makes sense for the application, such as being able to sort by keys in just one operation.

Satyam
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux