Hi Adam:
              I tried it but it wouldn't work. Can anybody else help,
please.
the original array is an output from a calculated find('all') as in:

$transaction_amount_total = $this->set('transaction_amount_total',
$this->Jurisdiction->Transaction->find('all',array('conditions'=>array
('Transaction.jurisdiction_id ='=>$id),'fields' => array
('Transaction.id','SUM(Transaction.amount) AS Amount'))));

I don't know if that has anything to do with why I can't any array PHP
functions like remove(), array_chunk(), array_slice() etc to work.


-sam

On Jun 15, 5:32 pm, "Adam Royle" <[email protected]> wrote:
> use this function, it works well...
>
> // recursively reduces deep arrays to single-dimensional arrays
> // $preserve_keys: (0=>never, 1=>strings, 2=>always)
> function array_flatten($array, $preserve_keys = 1, &$return = array()) {
>  foreach ($array as $key => $child) {
>   if (is_array($child)) {
>    $return =& array_flatten($child, $preserve_keys, $return);
>   } elseif ($preserve_keys + is_string($key) > 1) {
>    $return[$key] = $child;
>   } else {
>    $return[] = $child;
>   }
>  }
>  return $return;
>
> }
>   ----- Original Message -----
>   From: samuel darko
>   To: [email protected]
>   Sent: Tuesday, June 16, 2009 1:16 AM
>   Subject: array extraction
>
>   Hi guys:
>               i need help trimming down this:
>
> Array(  [0] => Array    (      [0] => Array       (         [Amount] => 72.64 
>       )     ))
>   TO this:
>
>  Array             (      [Amount] => 72.64     )I tried the ff code but to 
> no avail:function afterFind($results, $primary=false) {          if($primary 
> == true) {
>                    if(Set::check($results, '0.0')) {                  
> $fieldName = key($results[0][0]);                foreach($results as 
> $key=>$value) {                     $results[$key][$this->alias][$fieldName] 
> = $value[0][$fieldName];
>                           unset($results[$key][0]);                    }      
>               }           }                       return $results;        }   
>      Thanks, in advance, for your help
>   -sam
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to