<?php
$uptime = @system('uptime');
if ($uptime && preg_match("#average: ([0-9,\\.\\s]+)$#", $uptime, $loads)) {
echo "The average load is: " . number_format((array_sum(explode(", ", $loads[1])) / 3), 2);
} else {
echo "The uptime could not be determined";
}
?>
It’s just a very basic way to do it. Normally you should properly identify the values with REGEX, then make sure each load value is stripped or any spaces that might get from your output. It takes more resources to allocate variables and perform a foreach() or a for() but that’s what you have to do to make it flawless.