$one = $txt; break; } } //==============fill first record===============-------------------------------------- //trim space and comma $pathN = yakcatPathN($one); $categorie = new Cat($one, $one, $pathN, 1, '', $status); $succes = $categorie->saveToMongo($level = 1); //================fill record two====================================== $title2 = $two; $path2 = $one . ", " . $two; $pathN2 = $pathN . "#" . yakcatPathN($title2); echo "<br>" . $pathN; $categorie->setAncestors($one, $pathN); $categorie->setParent($one, $pathN); $categorie->title = $title2; $categorie->path = $path2; $categorie->pathN = $pathN2; $categorie->level = 2; $succes = $categorie->saveToMongo($level = 2); //exit; //insert db results for ID--here--------------------------- //--------------------------------------------------------- //==============fill third record================================= $title3 = $three; $path3 = $path2 . ", " . $title3; $pathN3 = $pathN2 . "#" . yakcatPathN($title3); $categorie->title = $title3; $categorie->path = $path3; $categorie->pathN = $pathN3;