The problem is that the addData function adds data to all variables but not to keywords array. As far as I can see, the keywords[1] is blank after the $keywords[]=$new_value; line. Why?? Here is my code:
class comment
{
var $id;
var $keywords;
//some other vars
// This is the constructor function which assigns id property, creates keywords array.
function comment($newID)
{
$this->id = $newID;
$keywords = array();
}
// This function is used to add data to one of the object's properties.
function addData ($prop, $new_value)
{ // Convert the property name to lower case.
$prop = strtolower($prop);
if ($prop=='keywords'){
$keywords[]=$new_value;
}
else
{
$this->$prop = $new_value;
}
}
}