Tuesday, November 27, 2012

Re: rearrange multidimensional array in cakephp 2.2

On Mon, Nov 26, 2012 at 6:59 PM, Marius <neculamarius@gmail.com> wrote:
> Hi all,
> I have this multidimensional assoc $modules array in cakephp 2.2.3:
> ...
> where it would be nice that 'category' would be sorted alphabetically within
> each parent 'type'
>
> I tried with
>
> $modules = Hash::combine($modules, '{n}', '{n}.{n}', '{s}.{s}.{n}.zone');
>
> but with no success. I guess I'm not using Hash::combine as I should...

Why not use Hash::sort()? I think you might have to run it through
each top-level array separately though.

Also, you could specify how to sort the associated records when Cake
fetches them.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.

No comments: