Hi,
I'm not a PHP programmer (but know other languages) and I'm trying to understand a web page that was done in PHP (5.1.6) in order to do some changes.
The page has the following code (simplified):
$db_hosts = array();
$sql = 'SELECT h.hostid, h.host FROM hosts h ';
$db_items = DBselect($sql);
while($db_item = DBfetch($db_items)){
$name = $db_item['host'];
$db_host = &$db_hosts[$db_item['hostid']];
}
What I'm trying to understand the last line $db_host = &$db_hosts[$db_item['hostid']];
It seems to be creating a new variable $db_host and putting something inside it, but don't understand &$db_hosts.
I'm in doubt because as far as I know, $db_hosts is an empty array.
I found this and this, but I'm not quite sure, because in this links, the operator is "=&", and in the code, the operator is attached to the variable "= &$db_hosts" (it has an space between = and &).
Since I tried to modify it and didn't got success, I thought that was better to ask for help...
TIA,
Bob