- var_dump: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$patern = '<html>
<head>
<link href="templates/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<title>TEST</title>
</head>
<body>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>#</th>
<th>Title</th>
<th>Category</th>
<th>date</th>
<th>Options</th>
</tr>
</thead>
<tbody>
{_begin_foreach=[atable]_}
<tr>
<td class="col-md-1">{_[atable.count]_}</td>
<td class="col-md-3"><a href="#">{_[atable.title]_}</a></td>
<td>{_[atable.category_id]_}</td>
<td>{_[atable.date]_}</td>
<td class="col-md-3">
<a href="#" id="{_[atable.id]_}" class="btn btn-primary edit">Edit</a>
<a href="#" id="{_[atable.id]_}" class="btn btn-warning delete">Delete</a>
</td>
</tr>
{_end_foreach=[atable]_}
</tbody>
</table>
</body>
</html>';
$fornum = preg_match_all("/\{_begin_foreach=\[(.*)\]_\}([\s\S|\n]*?)\{_end_foreach=\[\1\]_\}/", $patern, $foreach);
var_dump($fornum);
var_dump($foreach);