0

Hi
I have a variable like this :

$fulltext = '<h1>Welcome</h1> <h2>Welcome to this website</h2> <p>Some text here. </p>';

Now I want to get only Welcome to this website in another variable.

I want to copy text between <h2> and </h2>

I don't know how to do this?
Please help me

Thanks

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by nav33n
0
<?php
$reg = '/<h2>(.*)<\/h2>/s';
$fulltext="<h1>Welcome</h1> <h2>Welcome to this website</h2> <p>Some text here. </p>";
preg_match($reg,$fulltext,$matches);
print $matches[1];
?>

This will do.

0

Thanks a lot.
Can you give me any link to learn how to use "/" "(.*)" etc expressions?
I don't find any link related to this.

Thanks again

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.