while(list ... each()) question

admin

Administrator
Staff member
Hi folks, I want to display the contents of an array. I'm using code like this:

$row = mysql_fetch_array($result);

while (list ($key, $value) = each ($row)) {
echo ("$key . $value <br />");
}

However, the output is weird - every $name $value pair is repeated - once with a numeric index with the data, then with a string index and the data, e.g. for the first 3 elements of the array I get:

0 4
con_id 4
1 Andrew
firstname Andrew
2 Smith
surname Smith

Is there anyway of preventing the numeric index from displaying, or of trapping it?

Thanks, Tony.
 
Back
Top