NYCPHP Meetup

NYPHP.org

[nycphp-talk] autovivification/style question

David Mintz david at davidmintz.org
Thu Mar 17 12:35:53 EDT 2011


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.

-- 
David Mintz
http://davidmintz.org/
It ain't over:
http://www.healthcare-now.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20110317/c5f3a4e5/attachment.html>


More information about the talk mailing list