Searchingfor text within a string

From: Date: Sat, 26 Aug 2000 04:38:03 +0000
Subject: Searchingfor text within a string
Groups: php.general 
Request: Send a blank email to php-general+get-13771@lists.php.net to get a copy of this message
I'm trying to search for a piece of text within a long string. It is for a basic ping utility that will just provide a green or red light. An example string is: PING 1.1.1.1 (1.1.1.1): 56 data bytes --- 1.1.1.1 ping statistics --- 1 packets transmitted, 0 packets received, 100% packet loss (all on one line) This is the result of the following command: passthru('ping -c 1 2.1.1.1', $ping); echo $ping; I need to look for the '100%' part of the string and assign it as a variable. I'll do something like: if ($loss = '100%'){ display a red light; } else { display a green light; } Thanks, Pat

« previous php.general (#13771) next »