循环外的函数不更新

I'm trying to do a loop that display a few conditions based on load average and cpus/memory etc. However, it seems like it only pull the usage information once for the entire loop. I want it to update it on each loop: Here's what I got, any kind of help on this is great appreciated!

<?php

exec("cat /proc/cpuinfo | grep processor | wc -l",$processors);
$totalc=$processors[0];

function sys_getloadavg_hack()
{
    $str = substr(strrchr(shell_exec("uptime"),":"),1);
    $avs = array_map("trim",explode(",",$str));

    return $avs;
}

$load = sys_getloadavg_hack();

  function get_memory() {
  foreach(file('/proc/meminfo') as $ri)
    $m[strtok($ri, ':')] = strtok('');
  return 100 - round(($m['MemFree'] + $m['Buffers'] + $m['Cached']) / $m['MemTotal'] * 100);
}

function print_exec(){
$out_arr=array();
$last_line=exec("mpstat",$out_arr);
return $last_line;
}

   for ($i=1; $i<=50; $i++)
  {

$memory = get_memory(); 

$cpu = substr(print_exec(),-5);

if($memory>"10" && $cpu>"10" && $load[0]<$totalc) {

echo "Everything is good!";

    } else {

}
    echo "Memory: $memory || CPU: $cpu || Load AVG: $load[0] || #CPU's: $totalc<br> || #Runtime: $i

"; 
    usleep(800000);
}
    ?>

You have to make all calculations every loop. For example: You call sys_getloadavg_hack() only once before your loop.

Try to add the sys_getloadavg_hack() call in the for loop.

for(...)
{
    $load = sys_getloadavg_hack();
    ...
}