$hosts = array ( "host.domain.com", "host1.domain.com" ) $ports = array ( "8080", "8081" ) foreach ($hosts as $host) { foreach ($ports as $port) { if(fsockopen($host, $port)) { echo "$host:$port is up!\n"; } else { echo "$host:$port is NOT up!\n"; } ?>