PHP – regex get anything between tag html/xml

i have string in xml tag like this, and i need get what is between <w:t> tag and between <w:r>

$xml =<<<XML
<w:p w:rsidR="00E" w:rsidRDefault="00E">
 <w:r w:rsidR="000">

//  get all between w:t
preg_match_all('~<w:t>(.+?)<\/w:t>~', $xml, $m_t);


// get all between w:r
preg_match_all('~<w:r(.+?)<\/w:r>~s', $xml, $m_r);



to get w:r why we need extra s ???

becouse the $xml have newlines


Published by


just to remember what i had known :)

One thought on “PHP – regex get anything between tag html/xml”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s