// set start and end tags $starttag = ''; // escape characters that would mess up preg_match_all $starttagesc = preg_quote($starttag, '/'); $endtagesc = preg_quote($endtag, '/'); // match all instances and assign value to $results array preg_match_all("/$starttagesc.*?$endtagesc/", $post_body, $results); // example result //