preg_match

Match text between two lines, suppose we have three lines of text

 
line1
theme_name:theme1
line3
 

We want to extract out the theme name, here the "theme1" string. We use windows line ending format.

 
        preg_match('/line1\r\ntheme_name:([\s\S]*?)\r\nline3/', $text, $matches);
 

The matches will looks like

 
Array ( [0] => line1 theme_name:theme1 line3 [1] => theme1 )