You could assume that when no port is specified (ie. $port[0] is empty) then ping, otherwise use fsockopen on the specified port.
In line with the above suggestion, you could create an array for each target with host, desc, port...
$systems[] = array('host' => 'SRV001', 'desc' => 'SQL Server', 'port' => '1433');
Also, if you're monitoring websites it's not enough to just do a ping / check the port. The indicator of a website being down is by using HTTP status codes so perhaps do this when port 80 or 8080 is specified.