1<?php
2$ip_address = '123.456.789.0'; // IP address you'd like to ping.
3exec("ping -c 1 " . $ip_address . " | head -n 2 | tail -n 1 | awk '{print $7}'", $ping_time);
4print $ping_time[0]; // First item in array, since exec returns an array.
5?>
1exec("ping ".$ip, $output, $status);
2// $ip: desired ip address
3// $output: result messages from the ping
4// $status: result status code from the ping
5// 0: success
6// 1: no response
7// 2: other errors