Tuesday, December 6, 2011

Trying to reduce arrays

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: