สวัสดีครับ
ผมใช้ code นี้อยู่นะครับ
$ip = "127.0.0.1";
exec("ping -c 4 " . $ip, $output, $result);
print_r($output);
ผลออกมาคือ
Array (
- => PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data. [1] => 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.035 ms [2] => 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.020 ms [3] => 64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.023 ms [4] => 64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.023 ms [5] => [6] => --- 127.0.0.1 ping statistics --- [7] => 4 packets transmitted, 4 received, 0% packet loss, time 2998ms [8] => rtt min/avg/max/mdev = 0.020/0.025/0.035/0.006 ms )
ผมจะทำอย่างไรได้ให้มันออกมาเป็นแบบนี้ครับ(ตัวอย่าง)
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.040 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.021 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.023 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.023 ms
--- 127.0.0.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2998ms
rtt min/avg/max/mdev = 0.021/0.026/0.040/0.009 ms
ขอบคุณมากๆ เลยนะครับ