
Untitled
By: a guest on
Jun 17th, 2012 | syntax:
None | size: 0.55 KB | hits: 17 | expires: Never
Basic PHP collection
class entry
var $id
var $text
class comments
var $id
var $entryId
var $text
var $data_array;
function getCollectionById(){
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$da[$i] = array('entryId'=>$row["entryId"],'text'=>$text);
}
$this->data_array = $da;
}
$my_collection = array();
// some loop to populate your collection
$my_collection[] = new Comment(...); // adds a new object to the end of the collection
//end loop
foreach($my_collection as $comment):
print_r($comment);
endforeach;