hello all, i have a simple class where i take an array of objects and set them as a value for the object (and keep doing this in a loop of mysql rows)... but for some reason it stops after the 1st loop. i assume something maybe with pass by value or reference of the array into the class that i dont know about (i assume it makes a copy into the array but maybe by reference happens n' ruins the script?).
Anyway i debugged and without this line, it works...
$holidayArray->setArray( $holidayArray );
why does it error here? i need a way to set an instance to have its own array, am i doing soemthing wrong?
heres my code if anyone can help. Im a newb intpo php btw 🙂.
class DayInfo
{
public $holidayType;
public $holidayArray;
public function setType($theType)
{
$this->holidayType = $theType;
}
public function setArray($theArray)
{
$this->holidayArray = $theArray;
}
public function getType()
{
return $this->holidayType;
}
public function getArray()
{
return $this->holidayArray;
}
}
//..................
while($holiday = mysql_fetch_array($result))
{
$holidayName = $holiday['Holiday'];
$day = $holiday['day'];
$imageUsed = $holiday['ImageUsed'];
$imageName = $holiday['Image'];
echo( $holidayName . $day. $imageUsed. $imageName ."<br/>"); //testing
$holidayArray = array($holidayName, $imageUsed, $imageName );
$holiday = new DayInfo();
$holiday->setType("holiday");
$holidayArray->setArray( $holidayArray );
$monthList[$day][] = $holiday;
//unset($holiday );
}