communication
 databases
 directories
 file handling
 html and code
 image editing
 image listing
 sessions and co
 string handling
 information
 forms
 apple stuff
 image handling
 array handling
 lixlpixel
php - snippets
google search terms detected and highlighted.
remove highlighting | keep highlighting
make snippet in "string handling" - download "extract string from offsite" - open demo of "extract string from offsite"
 search
php - snippets

Valid CSS!

php webring logo
prev next
random list
join the Ring!

string handling - extract string from offsite was created/last modified on Mon 26 Apr 2004 12:32 AM

this will get parts of websites on remote servers

just specify words in the remote source to start and end the output

<?php
   
   
// the adress of the remote file to read
   
$off_site = 'http://fundisom.com/phpsnippets/snip';
   
// you have to backslash certain characters !
   
$start = '<title>';
   
$end = '<\/title>';

   
$fp = fopen ($off_site, 'r') or die('Unable to open file '.$off_site.' for reading');
   
   while (!
feof ($fp))
   {
       
$buf = trim(fgets($fp, 4096));
       
$cont .= $buf;
   }
   
   
preg_match("/$start(.*)$end/s",$cont,$match);
  
   echo
'the title of '.$off_site.' is <b>'.$match[1].'</b>';
   
   
?>

learn more about some of the PHP functions used in this snippet: die, echo, end, feof, fgets, file, fopen, for, ord, preg_match, trim, while

view the GNU general license - view the GNU library license - search on PHPsnippets - see your code like this

 a lixlpixel.com site

PHParadise.com - PHP-classes.org - your site on safari