Is it possible to display individual tags from one html file in another?

I want to create an informer that displays news headlines from the news page and I want to make it not display everything on the page, but only one specific heading tag.


Answer 1, authority 100%

I don’t know how smart it is, but it’s very easy
page1.php

$mode="only_news";
include('page2.php');

page2.php

global $mode;
if ($mode=='only_news') {
    ...
} else {
    ...
};

If page2.htmlis static, then you can do something like this

$text=file_get_contents('page2.html');
$news=preg_match_all("div class=news(.*?)\/div", $text, $result);

If page2.htmlis dynamic, then you can do something like this

$text=file_get_contents('http://mysite.com/page2.html');
$news=preg_match_all("div class=news(.*?)\/div", $text, $result);

Leave a reply

Please enter your comment!
Please enter your name here