-test.php includes next lines.
<?php
class Test extends AppModel
{
var $name = 'Test';
var $useTable = false;
function myfunction($i) {
switch($i)
{
case 1:
$result[0] = 'lemon';
$result[1] = 'banana';
$result[2] = 'apple';
case 2:
$result[0] = 'lion';
$result[1] = 'tiger';
$result[2] = 'monkey';
case 3:
$result[0] = 'red';
$result[1] = 'blue';
$result[2] = 'green';
}
return $result;
}
}
?>
-tests_controller.php includes next lines.
<?php
class TestsController extends AppController {
var $name = 'Tests';
function pass() {
for ($i = 1; $i <= 3; $i++) {
$result = $this->Test->myfunction($i);
$this->set('result',$result);
}
}
}
?>
-And, pass.thtml includes next lines.
<?php
$count = count($result);
for ($i=0; $i < $count; $i++) {
echo $result[$i] . "<br />";
}
?>
The run cakephp/tests/php gives only "colors":
red
blue
green
But, what I want is to get all of the fruits, animals, and colors as an
output:
lemon
banana
apple
lion
tiger
monkey
red
blue
green
Of course I could increase the dimension of $result array like
$result[$i][] and throw the whole information into the
View(pass.thtml). But as you know, the above code is a simple example
demonstrating my problem, and in real life it take much more time to
execute myfunction(scrapes and extracts other web pages) for the whole
run of $i. So I want to throw each $result for each $i "on the fly"
without collecting all the fruits, animals, and colors. As soon as
collecting fruits are done (the run for $i=1), fruits are listed on the
screen, and as soon as animals are collected($i=2), the animal array is
sent to View and so on.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---