3

I'm trying to match a string inside an HTML

for example I want to find the string inside <strong> string </strong>

what I'm doing is

preg_match_all('|\<strong\>(.*)\<\/strong>|',$html,$data);

echo $data[1][0];

it works when the string I want to search inside <strong> is not a line break but if it has a line break, how can I do it?

not working example:

<strong>
line break string
</strong>
Delimitry
  • 2,813
  • 4
  • 25
  • 36
user983124
  • 257
  • 3
  • 5
  • 8

1 Answers1

10

Use:

preg_match_all('/<strong>(.*)<\/strong>/s',$html,$data);
Darm
  • 5,189
  • 2
  • 17
  • 18