3v4l.org

run code in 300+ PHP versions simultaneously
<?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]*?)\{_end_foreach=\[\1\]_\}/smu", $patern, $foreach); var_dump($fornum); var_dump($foreach);

preferences:
64.09 ms | 402 KiB | 5 Q