OK,
I have several servers, each one run a service such as pop,smtp,http.
pop servers are pop1,pop2,pop3 ecc
http serve are web1,web2,web3 ecc
smtp server are smtp1,smtp2,smtp3 ecc
i create an array like this:
$target= array (
"smtp" => array ("1"=>"smtp1.csi",
"2"=>"smtp2.csi",
"3"=>"smtp3.csi",
)
"pop" => array ("1"=>"pop1.csi",
"2"=>"pop2.csi",
"3"=>"pop3.csi",
)
"web" => array ("1"=>"web1.csi",
"2"=>"web2.csi",
"3"=>"web3.csi",
)
);
I want to monitor services for every server on specific port with:
$fd=fsockopen($host,$port,$errno,$errstr,10);
If i use foreach three times it's easy
example:
foreach($target["smtp"] as $host){
$port="25";
$fd=fsockopen($host,$port,$errno,$errstr,10);
if (!$fd) {
$color="red";
$msg="not active";
}
else {
$color="green";
$msg="active";
fclose ($fd);}
//then i change target and port for two times, but in this way i have to use function foreach three times.
Now, what kind ok structure i need to use only one time the functio foreach?
I hope i explained good my problem?