Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 0.55 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Basic PHP collection
  2. class entry
  3. var $id
  4. var $text
  5.  
  6.  
  7. class comments
  8. var $id
  9. var $entryId
  10. var $text
  11. var $data_array;
  12.  
  13. function getCollectionById(){
  14.     while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  15.     $da[$i] = array('entryId'=>$row["entryId"],'text'=>$text);
  16.     }
  17.     $this->data_array = $da;
  18. }
  19.        
  20. $my_collection = array();
  21.  
  22. // some loop to populate your collection
  23.  
  24. $my_collection[] = new Comment(...); // adds a new object to the end of the collection
  25.  
  26. //end loop
  27.        
  28. foreach($my_collection as $comment):
  29.    print_r($comment);
  30. endforeach;