Tuesday, December 6, 2011

Re: Trying to reduce arrays

What euromark said, just do your own forloop and append them to a new
array.

On Dec 6, 1:58 pm, euromark <dereurom...@googlemail.com> wrote:
> you can always use foreach() ;)
> the set:: methods wont use anything else, either (internally)
>
> so its also the quickest way of doing it.
>
> On 6 Dez., 22:41, McScreech <scre...@sympatico.ca> wrote:
>
>
>
>
>
>
>
> > I am completely stumped. I have tried combinations of Set::extract,
> > Set::classicExtract, Set::combine, and Set::flatten to get the results
> > I show below. Perhaps this is a straight php question rather than
> > cakePHP?
>
> > 1) How do I obtain the results demonstrated?
> > 2) How do I extract the key _names_ from the third level? ('mother',
> > 'father', 'child', 'date')
>
> > $array = array(
> >         0 => array(
> >                 c1 => array(mother => '05-0000064'),
> >                 c2 => array(father => '05-0000740'),
> >                 p1 => array(child => 'WP-0000315'),
> >                 t1 => array(date => '1956-00-00')
> >         ),
> >         1 => array(
> >                 c1 => array(mother => '05-0000066'),
> >                 c2 => array(father => '05-0000745'),
> >                 p1 => array(child => 'WP-0000316'),
> >                 t1 => array(date => '1958-00-00')
> >         )
> > );
>
> > Many TIA, McS
>
> > I have an array like this:
> > Array
> > (
> >     [0] => Array
> >         (
> >             [c1] => Array
> >                 (
> >                     [mother] => 05-0000064
> >                 )
> >             [c2] => Array
> >                 (
> >                     [father] => 05-0000740
> >                 )
> >             [p1] => Array
> >                 (
> >                     [child] => WP-0000315
> >                 )
> >             [t1] => Array
> >                 (
> >                     [date] => 1956-00-00
> >                 )
> >         )
> >     [1] => Array
> >         (
> >             [c1] => Array
> >                 (
> >                     [mother] => 05-0000066
> >                 )
> >             [c2] => Array
> >                 (
> >                     [father] => 05-0000745
> >                 )
> >             [p1] => Array
> >                 (
> >                     [child] => WP-0000316
> >                 )
> >             [t1] => Array
> >                 (
> >                     [date] => 1958-00-00
> >                 )
> >         )
> > )
>
> > I would like to have an array like this:
> > Array
> > (
> >     [0] => Array
> >         (
> >             [mother] => 05-0000064
> >             [father] => 05-0000740
> >             [child] => WP-0000315
> >             [date] => 1956-00-00
> >         )
> >     [1] => Array
> >         (
> >             [mother] => 05-0000066
> >             [father] => 05-0000745
> >             [child] => WP-0000316
> >             [date] => 1958-00-00
> >         )
>
> > )

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


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

No comments: