Hello -
I am trying to create an array within an object function, and subsequently iterate through that array, but have been unsuccessful - here is how I've tried to accomplish the task:
function create_an_array_within_my_object()
{
$temp_var = array();
$query = ("SELECT * FROM myTable");
while($row = mysql_fetch_array($query))
{
$temp_var[$row[id]] = $row[otherVar];
}
$this->objectVar = $temp_var;
}
// later, I want to iterate through the objectVar...
foreach($object->objectVar as $individual)
{
echo $individual;
}
// This fails to trigger a loop, yet when I echo $object->objectVar, I return "Array"...
I am preplexed - is this possible? Any observations will be greatly appreciated.
Chris