oops - wrong! (was: how to alter assoc_array?)

From: Date: Sun, 11 Feb 2001 21:10:17 +0000
Subject: oops - wrong! (was: how to alter assoc_array?)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-39142@lists.php.net to get a copy of this message
Okay, I don't have it :) This should be recreating a 3 row array of key:value pairs with a "~" character prepended to each key, but is only echoing _one_ key:value pair - anyone see why? while($array = mysql_fetch_array($result, MYSQL_ASSOC)) { list($key, $value) = each($array); $key_prep="~$key"; $new_array=array("$key_prep => $value"); echo $key_prep; echo " assigned to "; echo $value; } outputs: ~boy assigned to hello where are my other two rows? :) regards, jaxon >>> If $array contains the following: >>> >>> boy => hello >>> girl => hi >>> dog => bark >>> >>> How can I alter all the elements the same way? >>> >>> e.g. so that it now conatins: >>> >>> Xboy => Xhello >>> Xgirl => Xhi >>> Xdog => Xbark >>> >>> thanks! >>> jaxon >>> >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, e-mail: >>> php-general-unsubscribe@lists.php.net >>> For additional commands, e-mail: >>> php-general-help@lists.php.net >>> To contact the list administrators, e-mail: >> php-list-admin@lists.php.net >> >> >> __________________________________________________ >> Do You Yahoo!? >> Get personalized email addresses from Yahoo! Mail - only $35 >> a year! http://personal.mail.yahoo.com/ >

« previous php.general (#39142) next »