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

From: Date: Sun, 11 Feb 2001 21:46:43 +0000
Subject: Re: oops - wrong! (was: how to alter assoc_array?)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-39145@lists.php.net to get a copy of this message
ack. ignore me. not enough coffee. the 'while' was in the wrong place. also dropped the array() in favor of array_name[] to ensure I keep it associative. $array = mysql_fetch_array($result, MYSQL_ASSOC); while (list ($key,$value) = each($array)) { $key ="~" . $key; $tagged_array[$key] = $value; } thanks! jaxon On 2/11/01 4:10 PM, "Jaxon" <jaxon@salamander.net> wrote: >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; >}

« previous php.general (#39145) next »