php-general | 2003022
Date: 02/23/03
- Next message: Anthony Rodriguez: "[PHP] Downloading files - Plz hlp"
- Previous message: Robert E. Harvey, M.D.: "Re: [PHP] simple ereg question"
- In reply to: Levi Zander: "[PHP] [!NEWBIE ALERT!] fread() question"
- Next in thread: Levi Zander: "Re: [PHP] [!NEWBIE ALERT!] fread() question"
- Reply: Levi Zander: "Re: [PHP] [!NEWBIE ALERT!] fread() question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 00:05 24-2-2003, you wrote:
>trying to parse a URL and write html code to a file, then search the file
>for a string between <TITLE> ... </TITLE> how would I implement the fread
>function below, and regular expressions to read the specific conent. thx
>
>or is there a php function that can return the TITLE of a URL?
>
><?php
>$string = implode("", file($url));
>$fp = fopen("temp.txt", "w");
>fwrite($fp, $string);
>fclose($fp);
i would read in the entire file, and use a 'regular expression' such as
ereg() http://nl.php.net/manual/nl/function.ereg.php explained on
http://www.phpbuilder.com/columns/dario19990616.php3
or preg_match http://nl.php.net/manual/nl/function.preg-match.php
I think this may work, with the $string from your code:
$pattern="/<title>(.*)<\/title>/i";
preg_match($pattern, $string, $matches);
$title=$matches[1];
echo $title;
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Anthony Rodriguez: "[PHP] Downloading files - Plz hlp"
- Previous message: Robert E. Harvey, M.D.: "Re: [PHP] simple ereg question"
- In reply to: Levi Zander: "[PHP] [!NEWBIE ALERT!] fread() question"
- Next in thread: Levi Zander: "Re: [PHP] [!NEWBIE ALERT!] fread() question"
- Reply: Levi Zander: "Re: [PHP] [!NEWBIE ALERT!] fread() question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

