The for loop could probably be replaced by an array_filter() function (see the docs) that does the test, prints the error and returns false in the event of non-SNMP (and true otherwise). Call it check_snmp(), say and have
$boxen=array_filter($boxen,'check_snmp');
with check_snmp() looking like
check_snmp($box)
{
global $str;
$infocheck = @snmpget("$box", "$str", "system.sysDescr.0");
if(! $infocheck)
{
print "SNMP doesn't appear to be running on $boxen[$i]<br>\n";
}
return $infocheck;
}
Note that $str is declared global - otherwise it would be an (unset) local variable. Of course, $global has to be declared and have a value at the point where the function is defined.