Re: help with multidimentional arrays

From: Date: Wed, 12 Apr 2006 14:37:45 +0000
Subject: Re: help with multidimentional arrays
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-233837@lists.php.net to get a copy of this message
> On 4/11/06, Bing Du <bdu@iastate.edu> wrote: >> => foreach ($sponsor_id as $sponsor => $arr) >> echo "$sponsor:"; >> foreach ($arr[$sponsor] as $project) { >> echo "$project<br>"; >> } >> => > > It looks like you're building your array just fine. Here though, your > second foreach needs to look like this: > > [code] > foreach ($arr as $project) > { > echo "$project<br>"; > } > [/code] > > Your temprorary $arr variable contains only your array of titles, not > an entire row of your 2-dimensional $sonsor_id array. So you do not > need to use the $sponsor key to get at that array. > Thanks so much for pointing out that error on $arr, John. You are very right. Now I realize it's such an obvious error. But I did not notice it before I posted. Bing

« previous php.general (#233837) next »