for loop - Why does my PHP code doesn't work anymore for no reason? -


i have loop in code. haven't changed on part of code 5-6 days , never had problems it.

since yesterday tried reload code , allways gives me error:

maximum execution time of 30 seconds exceeded - in logcontroller.php line 270 

well can't explain why maybe of on it.

this code around line 270.

$topten_sites = []; ($i = 0; $i <= count($sites_array); $i++) {     if ($i < 10) { // 270         $topten_sites[] = $sites_array[$i];     } } $topten_sites = collect($topten_sites)->sortbydesc('number')->all(); 

as said, worked perfectly, why gives me error? if uncomment these lines , every other line contains $topten_sites array, code workes again.

this looks wrong:

    ($i = 0; $i <= $sites_array; $i++) {         if ($i < 10) { // 270             $topten_sites[] = $sites_array[$i];         }     } 

if $sites_array array, makes no sense compare integer have never-ending loop.

if need first 10 elements in array, can replace loop with:

$topten_sites = array_slice($sites_array, 0, 10); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -