public static function loop() { if (substr(time(), -1, 1) != substr(self::$last_time, -1, 1)) { self::$last_time = time(); core::$network_time++; // new time, also network time gets ++'d core::$uptime++; // another second added. foreach (self::$timers as $tid => $data) { $class = $data['class']; $method = $data['method']; $params = $data['params']; // set up some variables. if (self::$timers[$tid]['count_timer'] == $data['timer']) { if (is_callable(array($class, $method), true) && method_exists($class, $method)) { if ($params == '') { call_user_func_array(array($class, $method)); } else { call_user_func_array(array($class, $method), $params); } } // execute the callback, with parameters if defined. self::$timers[$tid]['count_timer'] = 0; self::$timers[$tid]['count_times']++; // reset the counter back to 0, so it's executed again // and ++ our count_times if (self::$timers[$tid]['count_times'] == $data['times'] && $data['times'] != 0) { unset(self::$timers[$tid]); continue; } // check if it's the last time we're to execute it // if so, cut the timer off. // if times is 0, which means indefinatly, just keep running it. } self::$timers[$tid]['count_timer']++; // ++ } // loop though the set timers. // ++'ng each one of them, then checking against their // execution time. } }