Reading a text file from PHP

  OK Computer 18:12 24 Mar 06
Locked

Hi,

I'm currently reading a text file via PHP which, in itself, is very easy. However I want to specifically get one word from the text file and assign it as a variable and I'm struggling like mad! The text file is just a ping result, as follows:

Pinging click here [64.233.183.147] with 32 bytes of data:

Reply from 64.233.183.147: bytes=32 time=34ms TTL=249
Reply from 64.233.183.147: bytes=32 time=32ms TTL=248
Reply from 64.233.183.147: bytes=32 time=31ms TTL=248
Reply from 64.233.183.147: bytes=32 time=32ms TTL=249

Ping statistics for 64.233.183.147:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 31ms, Maximum = 34ms, Average = 32ms

What I really want to do is get the word reply out of the text file so I can do a simple if statement that says If $variable="Reply" then the ping has been successful otherwise it has failed.

Does this make sense? Can anyone point me in the right direction?

  harristweed 08:17 25 Mar 06

<?php

$file="[64.233.183.147] with 32 bytes of data:

Reply from 64.233.183.147: bytes=32 time=34ms TTL=249
Reply from 64.233.183.147: bytes=32 time=32ms TTL=248
Reply from 64.233.183.147: bytes=32 time=31ms TTL=248
Reply from 64.233.183.147: bytes=32 time=32ms TTL=249

Ping statistics for 64.233.183.147:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 31ms, Maximum = 34ms, Average = 32ms";

$match="Reply";

if(strstr($file, $match))
{
$found="the ping has been successful";
}else{$found="the ping has failed";
}
echo($found);

?>

  OK Computer 10:54 25 Mar 06

You are a king amongst men! Read in the text file, used the if statement and I'm sorted! Thanks!!!

This thread is now locked and can not be replied to.

Nintendo Switch review: Hands-on with the intuitive modular console and its disappointing games…

1995-2015: How technology has changed the world in 20 years

This abstract video touches on division in our technologic world

Best alternatives to iTunes for Mac | Best music players for macOS: Free your music from the…