Thursday, June 25, 2009

Problem returning array from function

Hi All

I have a function in a component. Basically the aim of it is to
create a breadcrumb menu eg: Gallery > 2009 Photos > Winter Games

My problem is that if there is more than one element/value in the
array it doesnt seem to return anything. I know that the array is
being generated though because I can print_r it out within the
function. It seems to be getting lost somewhere between the component
and controller

In My controller:

$breadCrumbs = $this->GalleryFunctions->makeBreadcrumb(array($id),
$id);
print_r($breadCrumbs);

In My Component:

function makeBreadcrumb($array, $id){

// find the parent of the cat
$parent = $this->GallerysCat->find("GallerysCat.id = '$id'",
"parent");
$parent = $parent['GallerysCat']['parent'];
if($parent == 0){
$reverse = array_reverse($array);
print_r($reverse); echo "<br><br>";
return $reverse;

}
else{
$array[] = $parent;
$this->makeBreadcrumb($array, $parent);
}
}


Any Ideas?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: