The object is to find sets such as <!-- content:start -->some content here<!-- content:stop -->
and process each one to put it into an array, but every time it find no matches and echos my die statement without printing any matches out. Note: The content in between the start and end tags usually spa开发者_如何学Cns multiple lines.
This is the current function that is being executed.
function boom($data) {
$number = preg_match_all("/(<!-- ([\w]+):start -->)(.*?)(<!-- \\2:stop -->)/", $data, $matches, PREG_SET_ORDER);
if ($number == 0) $data['content'] = $data;
//else unset($data);
foreach ($matches as $item) print_r($item)."\n\n"; // $data[$item[2]] = explode("<!-- breaker -->", $item[3]);
die("<code>".str_replace("\n", "<br />", htmlentities($data))."</code>");
return $data;
}
If your text goes on multiple lines, just add the /s
modifier to your pattern (to make .
match newlines).
精彩评论