2007/1/3, skyblueink <[EMAIL PROTECTED]>:
I have no choice but to call $this->set() one thousand times in
Controller, and write foreach statement one thousand times in View.

Maybe you could make myfunction() a little bit more intelligent?

function myfunction($i) {
  switch($i)
  {
    case 1:
      $result[0] = 'lemon';
      $result[1] = 'banana';
      $result[2] = 'apple';
      $return = array('title' => 'Fruits are here', 'things' => $result);
      break;
    case 2:
      $result[0] = 'lion';
      $result[1] = 'tiger';
      $result[2] = 'monkey';
      $return = array('title' => 'Animals are here', 'things' => $result);
      break;
    case 3:
      $result[0] = 'red';
      $result[1] = 'blue';
      $result[2] = 'green';
      $return = array('title' => 'Colors are here', 'things' => $result);
      break;
  }
  return $return;
}

Your controller can call myfunction() any number of times you like,
collect all arrays and make them available to the view.

In the controller:

function pass() {
  $result = array();
  for ($i = 1; $i <= 3; $i++) {
     $result[] = $this->Test->myfunction($i);
  }
  $this->set('results',$result);
}



In the view:

foreach($results as $result) {
 echo "Header:" . $result[title];
 foreach($result[things] as $thing) {
   echo $thing;
 }
}

Not quite sure what you are trying to accomplish, however.

Martin

--
 Martin Schapendonk, [EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to