I have a function which is returning some values. I want to put those values in an array after checking if the current value exists. I 've written the following code:
$return[0]=myexec_proc($varsearch,$get_input1);
if (isset($return[0])){
$return[1]=myexec_proc($varsearch,$return[0]);
}
if (isset($return[1])){
$return[2]=myexec_proc($varsearch,$return[1]);
}
if (isset($return[2])){
$return[3]=myexec_proc($varsearch,$return[2]);
}
if (isset($return[3])){
$return[4]=myexec_proc($varsearch,$return[3]);
}
which works as I want to but I need to do it with a for loop.
I've tried this:
$return=array();
for($i=0; $i=3; $i++){
if (isset($return[$i])){
$return[$i+1]=myexec_proc($varsearch,$return[$i]);
}}
but I get no data and after a while I get a php fatal error "Maximum execution time of 30 seconds exceeded".
Any tips on what I am doing wrong would be appreciated.
for($i=0; $i<=3; $i++){
- yours will loop infinitely, as you noticed.