Sunday, June 28, 2009

Re: Problem returning array from function

No, I dont think so. I have no trouble building the array because
this line:

print_r($reverse); echo "<br><br>";

does print the entire correct array. Its returning it from the
function when there is more than one value in the array that gives me
a problem.

On Jun 26, 8:23 pm, John Andersen <j.andersen...@gmail.com> wrote:
> In the else statement, are you sure you don't need to do something
> with the returnedarrayfrom $this->makeBreadcrumb(...)?
>
> Enjoy,
>    John
>
> On Jun 26, 1:08 am, Sanfly <san...@gmail.com> wrote:
>
> > Hi All
>
> > I have afunctionin 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
> >arrayit doesnt seem to return anything.  I know that thearrayis
> > 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:
>
> >        functionmakeBreadcrumb($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: