I am working in Yii. I have following function in controller-
public function actiongetDnySubjectLink()
{
$contentTitleId=1;
$category=new Dnycontentcategories();
$record=$category->getCheckByParentTitleId($contentTitleId);
foreach ($record as $rec)
{
echo "</br>"."Main category is: " .$rec->childTitleId;
$parent=$category->getCheckByContentTitleId($rec->childTitleId);
echo $parent->englishTitle;
$record1=$category->getCheckByParentTitleId($rec->childTitleId);
foreach ($record1 as $rec)
{
echo "subcategory is :".$rec->childTitleId;
$child=$category->getCheckByContentTitleId($rec->childTitleId);
$childlist[]=$child->englishTitle;
echo $child->englishTitle;
}
echo CJSON::encode(array("parent"=>$parent->englishTitle,"child"=>$childlist))."</br>";
}
}
So i want to send parent and its children in json format. But $childlist[] array is storing all children of all parents. So how to refresh this array in order to store only current parents children . i.e. how to make array as empty before storing new parent's children . please help me