php - Can echo true but wont return -
im trying return true when loop has finished not seem happen. can echo true or false or text returning nothing.
wonder if explain why is.
here (kinda) function have removed data base calls , such not important.
function loop_me(){ // part not important... $finished = false; $done = 0; $userc = 1000; $page = 0; $count = 10; $array = array() $data = array('1','2','3') // big array of data... if($done < $userc){ for($i=0; $i<$count; $i++){ $array[] = $data[$i]; } // bellow important part... if($done >= $userc){ $finished = true; }else{ $page++; loop_me(); } } if($finished){ // if echo true outputs 1 (this fine) // if return true nothing got want if statement on // output, can't if not. echo(true); } }
ok function issue above out, basic idea of function loops thought array of data (not showen above) data paginated needs go next 'page' once finished first , there few pages want when has finished looping thought return true.
might simple fix.
but can't work out.
you called 'loop_me()' recursively, need return it.
}else{ $page++; return loop_me(); }
and of course change echo return too!
Comments
Post a Comment