Cakephp using the returned array values -


i guess should smple, have been stuck @ while need help. have cakephp application , getting following array:

chratsortedmean= array(     'totalaucfourhour' => array(         'screening visit-1 (scr)' => array(             'mmttfourthhour' => array(                 'totalaucs' => array(                     (int) 0 => (float) 0,                     (int) 1 => (float) 220                 )             )         ),         'month12' => array(             'mmttfourthhour' => array(                 'totalaucs' => array(                     (int) 0 => (float) 263.25,                     (int) 1 => (float) 16.25                 )             )         )     ),     'totalauctwohour' => array(         'day0' => array(             'mmttsecondhour' => array(                 'totalaucs' => array(                     (int) 0 => (float) 0,                     (int) 1 => (float) 112.125                 )             )         ),         'dayd2' => array(             'mmttsecondhour' => array(                 'totalaucs' => array(                     (int) 0 => (float) 97.375,                     (int) 1 => (float) 4.5                 )             )         ),         'month3' => array(             'mmttsecondhour' => array(                 'totalaucs' => array(                     (int) 0 => (float) 8.53125,                     (int) 1 => (float) 8.75                 )             )         )     ) ) 

i want calculate mean of totalaucs values each of timepoints(screening visit-1 (scr) , month12, day0 etc.) separately totalaucfourhour , totalauctwohour individually.

so result want in following form:

'totalaucfourhour' => array(         'screening visit-1 (scr)' => array(             'mmttfourthhour' => array(                 'totalaucmean' => (float) 110                 )             )         ),                 'month12' => array(             'mmttfourthhour' => array(                 'totalaucmean' => (float) 139.75                  )             )         )     ), 

and on. not want use multiple loops expect data grow in future.

cakephp has core utility classes 1 of named set. set array manipulation class. can call anywhere in app with:

set::methodnane(); 

what need extract(); or classicextract(); methods. usage simple:

$day0path = '/chratsortedmean/totalauctwohour/day0/mmttsecondhour' $arrayofday0s = set::extract($day0path, $data); 

check other possibilities @ cake book. since cakephp 2.2 there new array manipulation class hash , faster. since version set deprecated it not removed until cake 3.0.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -