Daric
Daric

Reputation: 16769

Getting the string between specified pattern PHP

I have string like this

$string = "<!--:en-->English Characters<!--:--><!--:zh-->日本<!--:-->";

I'm only interested with the content between <!--:zh--><!--:-->;

How can I do this?

Upvotes: 0

Views: 79

Answers (1)

Nipun Tyagi
Nipun Tyagi

Reputation: 898

preg_match( '/<!--:zh-->(.*?)<!--/', $string, $matches);

print_r($matches[1]);

Upvotes: 4

Related Questions