Phil,
For most things it is better to have the data the way it is returned.
I would encourage you to work within the framework and not against it.
That said, maybe you have some logic that is legacy like I do. I am
porting a clumsy mess of code into Cake but it cannot be done all at
once. I have old methods that want the data in a flat associative
array as you describe. In my AppModel class I put:
/**
* Totally flatten an array.
*/
function & array_flatten(&$array) {
if (is_array($array)) {
$newarray = array();
foreach ($array as $k=>$v) {
if (is_array($v)) {
$newarray += $this->array_flatten($v);
} else
$newarray[$k] = $v;
}
return $newarray;
}
return $array;
}
Then to use:
$newarray = array();
foreach ($results as $v) {
$newarray[] = $this->User->array_flatten($v);
}
HTH,
DL
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Cake PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---