I've searched through the stack for an answer but it seems that I cannot find a solution for the following code:
$servers = array();
while($row = mysql_fetch_array( $result ))
{
$servers[] = $row['name'] => array('ip' => $row['ip'],'port' => $row['port'],'info' => $row['info'],'purpose' => $row['purpose']),
}
What I'm trying to achieve is fetch all results but I receive the following error:
syntax error, unexpected '=>' (T_DOUBLE_ARROW).
Making it like this gets only the last item:
while($row = mysql_fetch_array( $result )) {
$servers = array(
$row['name'] => array('ip' => $row['ip'],'port' => $row['port'],'info' => $row['info'],'purpose' => $row['purpose']),
);
}
That being said, $servers is in the while loop, thus making it index only the last item. I don't know what causes the unexpected => :/