![]() |
|
|
+ Search |
![]()
|
Sep 29th, 2004 12:43
Gabriele F, Mark Aubrey,
Try: <?php $matches = array(); $url = 'http://some.server.somwhere.net/path/file.php'; $array_of_lines = file($url); if($array_of_lines) { $html = implode('', $array_of_lines); if( preg_match( '/Hits: (\d+)/',$html ) ) { echo "Found $matches[1] Hits!\n"; } else { echo "Uhhh.... did not find any matches.\n"; } } else { echo "I tried and tried but could not read '$url'.\n"; } ?> Or for PHP 4.3.0 or later, a slightly cleaner version: <?php $matches = array(); $url = 'http://some.server.somwhere.net/path/file.php'; $html = file_get_contents($url); if($html) { if( preg_match( '/Hits: (\d+)/',$html ) ) { echo "Found $matches[1] Hits!\n"; } else { echo "Uhhh.... did not find any matches.\n"; } } else { echo "I tried and tried but could not read '$url'.\n"; } ?> NOTE: "allow_url_fopen" must be set to "on" in your "php.ini" or "httpd.conf" file. SEE ALSO: http://www.php.net/manual/en/function.preg-match.php http://www.php.net/manual/en/function.file.php http://www.php.net/manual/en/function.file-get-contents.php http://www.php.net/manual/en/function.ini-set.php