On Tue, April 11, 2006 1:58 pm, Bing Du wrote: > What I intend to do is put the database query results in a > multidimentional array like this. > > $sponsor_id['sponsor1'] = ('project1 title', 'project2 title', > 'project3 > title'); > $sponsor_id['sponsor2'] = ('project1 title','project7 title'); > .... > > Here is the code snippet for doing that: > > == > while( ($rec = odbtp_fetch_array($qry)) ) { echo "rec[1] is: $reg[1]<br />\n"; > if (empty($sponsor_id[$rec[1]])) { > $sponsor_id[$rec[1]] = array(); > } else { echo "adding $rec[0] to $rec[1] array<br />\n"; > array_push($sponsor_id[$rec[1]], $rec[0]); > } > } > == > > Now, when the following code is used to print the array $sponsor_id, > it > only prints out the keys of the array which are: > > sponsor1 > sponsor2 > > Those project titles are not printed out. > > == > foreach ($sponsor_id as $sponsor => $arr) > echo "$sponsor:"; > foreach ($arr[$sponsor] as $project) { > echo "$project<br>"; > } > == > > My expected output should be like: > > sponsor1: > project1 title > project2 title > project3 title > > sponsor2 > project1 title > project7 title > > What is wrong? I'd appreciate any help. > > Thanks, > > Bing > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php