Re: [PHP] Unexpected values in an associative array[Solved]
- From: robert@xxxxxxxxxxxxx (Robert Cummings)
- Date: Tue, 31 Jul 2007 11:39:13 -0400
On Tue, 2007-07-31 at 11:29 -0400, Ken Tozier wrote:
Turns out that objects returned from SQL queries contain two parts
for every field, one with a string key and one with an index key.
Adding an "is_numeric" test on the keys allows you to filter out the
numeric keys if you want to. For example:
foreach ($row as $key => $value)
{
if (!is_numeric($key))
{
/* do stuff here */
}
}
BAH, use the correct function. You're using mysql_fetch_array() when you
SHOULD be using mysql_fetch_assoc().
Cheers,
Rob.
--
............................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
............................................................
.
- References:
- Unexpected values in an associative array
- From: Ken Tozier
- Re: [PHP] Unexpected values in an associative array[Solved]
- From: Ken Tozier
- Unexpected values in an associative array
- Prev by Date: Re: [PHP] Unexpected values in an associative array
- Next by Date: Re: [PHP] Unexpected values in an associative array[Solved]
- Previous by thread: Re: [PHP] Unexpected values in an associative array[Solved]
- Next by thread: Re: [PHP] Unexpected values in an associative array[Solved]
- Index(es):