On Thu, Mar 17, 2011 at 12:35 PM, David Mintz <da...@davidmintz.org> wrote: > Is there anything wrong with something like... > > $data = array(); > $results = $db->query($sql); > > while ($row = $results->fetch()) { > // ... this right here: > $data[$row->id][] = $row->someStringValue > } > > You can see I am trying to build up an array of arrays whose the keys are id > numbers and whose values are arrays of strings. I have tried it and it works > fine. I just wonder if it's kosher as a matter of cleanliness and style.
To avoid future warnings, I'd probably throw an if ( !isset($data[ $row->id ]) ) { $data[ $row->id ] = array(); } in there. _______________________________________________ New York PHP Users Group Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk http://www.nyphp.org/Show-Participation