Thanks, Martin. I'll try your suggestion. What I am trying to accomplish was posted here today.
http://groups-beta.google.com/group/cake-php/browse_thread/thread/8968aaa372cc1e67 Any comments will be much appreciated. On 1 4 , 9 47 , "Martin Schapendonk" <[EMAIL PROTECTED]> wrote:
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 cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---