Jump to content

[SOLVED] How to get segments from a page?


plznty

Recommended Posts

How would I go about using PHP to get bits of a page for example.

 

example.com/index.html -

<html>
<title>Example page 1</title>
</html>

 

How would I use php on my page to just gather the "Example page 1" part and not the rest.

Could you give me the php how I would do that for this particular example of explain please.

Would be appreciated. Thanks!

Link to comment
https://forums.phpfreaks.com/topic/175782-solved-how-to-get-segments-from-a-page/
Share on other sites

$s = '<html><title>Example page 1</title></html>';
preg_match('/<title>(.*)<\/title>/', $s, $m);
echo $m[1];

 

is there a way i can do it without having to insert thier page code. Something like include. So it could be updatable as the other page updates.

Example.com/index1.html on 01/01/2010

<html>
<title>Example page 1</title>
</html>

 

Example.com/index2.html on 02/01/2010

<html>
<title>Example page 2</title>
</html>

 

Ide like my page to be able to pickup the current title part.

So must need to get information from external sources rather than pasting in my own page

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.