Perhaps I'm going about this the wrong way, but I have, at least, found out what the problem is.
There are many keys with the same name.. of course, when a new key/value pair is read with the same key name, it overwrites the previous value! How can I read several lines into an array when the keys are the same? I can't can I...?
Has anyone got any workarounds, or perhaps an alltogether new approach that I haven't thought of, to get around this problem?
This is the code I have so far:
function whois($query, $server="localhost"){
$fp = fsockopen ("$server", 43, $errno, $errstr, 30);
if (!$fp) {
$ret[] = "$errstr ($errno)\n";
}else{
fputs ($fp, "$query\r\n\r\n");
$count=1;
while (!feof($fp) && $count < 110) {
$back = fgets ($fp,128);
$data = explode(":",$back);
$ret[$data[0]] = trim($data[1]);
$count++;
}
fclose ($fp);
}
return $ret;
}
The problem is that every time a new 'remarks' line is read (or any line that has a duplicate 'key', as far as the above function is concerned, the value gets overwritten. 😕