Re: Searchingfor text within a string

From: Date: Tue, 29 Aug 2000 15:59:00 +0000
Subject: Re: Searchingfor text within a string
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-14157@lists.php.net to get a copy of this message
pbrown@sla.com ("Patrick Brown") writes: > I just tried that with no success. I always get "Green Light". Here's the > code I used: > > <? > passthru('ping -c 1 1.1.1.1', $string); > echo $string; > echo "<br>\n"; > if(strstr($string,"100%")){ > echo "Red Light<br>\n"; > } else { > echo "Green Light<br>\n"; > } > ?> OK, passthru doesn't put the output of ping in $string, it puts the return value of ping in it, ie. false if there were no errors and true if something went wrong. If you want the actual output of ping, try using backticks like so: $string = ping -c 1 127.0.0.1; -robin -- Robin Vickery............................................... Planet-Three, 3A West Point, Warple Way, London, W3 0RG, UK Email: robin@planet-three.net Phone: +44 (0)870 729 5444

« previous php.general (#14157) next »