This could be the problem in your for loop: $elementKey = key( $macroDataArray ) - you're using the = assignment operator. Try == or <=.
Mike ----- Original Message ----- From: "Chris Boget" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, February 04, 2002 8:29 AM Subject: [PHP] Oddity > 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 > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php