RE: [PHP] Dispalying Arrays - Again

From: Date: Tue, 15 Apr 2003 01:48:22 +0000
Subject: RE: [PHP] Dispalying Arrays - Again
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-143858@lists.php.net to get a copy of this message
you change the names a little bit in the "what i'm looking for" section, but i'm assuming that was just shorthand: <? $z['user'] = array('vernman', 'Marc', 'rich96', 'lata7'); $z['distance'] = array(0 => 0.0, 4 => 14.9, 9 => 15.0, 1 => 67.6); foreach($z['user'] as $k => $v){ echo $v . ", " . array_shift($z['distance']) . "<br>"; } ?> you might just want to think about how you store the data in the arrays when fetching from the db call results... this method works, just be careful with it as it doesn't feel to me to be good programming technique... jack > -----Original Message----- > From: Vernon [mailto:vernon@comp-wiz.com] > Sent: Monday, April 14, 2003 9:28 PM > To: php-general@lists.php.net > Subject: Re: [PHP] Dispalying Arrays - Again > > > OK, thanks fo rthe suggestions, but that doesn't answer my question. > Now I have: > > do { > //SET ARRAYS > $z['username'][] = $row_rsUSERS['username']; > $z['distance'][] = $totaldist; > } while ($row_rsUSERS = mysql_fetch_assoc($rsUSERS)); > > asort ($z['distance']); > reset ($z['distance']); > > foreach ($z['username'] as $key => $value) { > echo "$key = $value<br>\n"; > } > > foreach ($z['distance'] as $key => $value) { > echo "$key = $value<br>\n"; > } > > Which displays something like this: > > for $z['username'] > 0 = vernman > 1 = Marc > 2 = rich69 > 3 = lata7 > > for $z['distance'] > 0 = 0.0 > 4 = 14.9 > 9 = 15.0 > 1 = 67.6 > > which what I'm looking for is > vernman, 0 > Marc, 14.9 > rich, 15.0 > lata, 67.6 > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#143858) next »