1

I'm trying to exctract some string inside a pattern.

the string is

<br /><br /><br />Text i want here
<br /></div>

i want the: "Text i want here"

My attemp was

preg_match('!<br /><br /><br />(.*?)<br /></div>!xi', $homepage, $matches);

But failed.

**I use the x because may between
they have some white space or \n.

<br />
<br />
<br />Text u want here
<br /></div>
1

1 Answer 1

1

use strip_tags("<br /><br /><br />Text i want here<br /></div>").

strip_tags will strip all HTML and PHP tags from a string.

Sign up to request clarification or add additional context in comments.

3 Comments

If you want to stick to regular expressions though you would need to take into consideration that your original string is multiline and that is why it's not matched. You should try using the s modifier and allow for matching newline characters between tags (e.g. !<br />.*<br />.*<br />(.*)<br />.*</div>!s will do)
@Muthu Kumaran This is a full html doc so i cant just strip the tags because i want a specific part on the whole html :).
@ Michal Trojanowski I try that but still nothing. :/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.