Oddity

From: Date: Mon, 04 Feb 2002 16:29:49 +0000
Subject: Oddity
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-83413@lists.php.net to get a copy of this message
Ok, could someone tell me why this isn't working? (note, I took out all my error checks. This is just the relevant code... $query = "Query that does return row(s)"; $result = mysql( $dbname, $query ); $macroDataArray = mysql_fetch_array( $result ); for( reset( $macroDataArray ); $elementKey = key( $macroDataArray ); next( $macroDataArray )) { echo "Value for key $elementKey = $macroDataArray[$elementKey]<br>\n"; } // this should spit out one line for every element. That doesn't work but this does: foreach( $macroDataArray as $elementKey => $elementValue ) { echo "Value for key $elementKey = $elementValue<br>\n"; } // this spits out 2 lines for every element. Why? What's going on? I could use the second bit of code, but that returns four pairs for each array element: ELEMENT VALUE 0 5000 KeyName 5000 for example, where the above is the same element. I really don't need the numerical "key" (the 0 above), just the name and that's why I need to find out why the first FOR loop isn't working. Any ideas? I've tried everything... :( Chris

« previous php.general (#83413) next »