CodeIgniter Forums
returning multidimensional array - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: returning multidimensional array (/showthread.php?tid=46789)



returning multidimensional array - El Forum - 11-15-2011

[eluser]Todlerone[/eluser]
Hello all and TY in advance for any help/suggestions. I have some code that I re-use quite alot. I tried to create a function within my class to call. It does work but I only get one value and not the hundreds that I expect. Here is the code I want to re-use.

Code:
switch($unit){
   case 'Cyberknife':
      if ($ps['treat_unit'] == "Cyberknife"){
         $rangeSEL[$data['year']][$brainDIAG] +=1;
      }
      break;

   case 'Trilogy':
      if ($ps['treat_unit'] == "Trilogy"){
        $rangeSEL[$data['year']][$brainDIAG] +=1;
      }
      break;

   case 'Both':
      if (($ps['treat_unit'] == "Cyberknife") || ($ps['treat_unit'] == "Trilogy")){
         $rangeSEL[$data['year']][$brainDIAG] +=1;
      }
      break;
}
I tried this function call
Code:
$rangeSEL=$this->chartshow($unit, $ps['treat_unit'], $brainDIAG, $data['year']);
with this function.
Code:
function chartshow($unitPOST, $unitDB, $holder, $year){
  switch($unitPOST){
   case 'Cyberknife':
    if ($unitDB == "Cyberknife"){
     $SEL[$year][$holder] +=1;
    }
    break;
   case 'Trilogy':
    if ($unitDB == "Trilogy"){
     $SEL[$year][$holder] +=1;
    }
    break;
   case 'Both':
    if (($unitDB == "Cyberknife") || ($unitDB == "Trilogy")){
     $SEL[$year][$holder] +=1;
    }
    break;
  }
  return $SEL;
}

TY....