通过正则表达式获取匹配内容

$content = "<!-- layout::public:index::30 -->";
$find = preg_match_all("/<!-- layout::(.+?)::(.+?) -->/is",$content,$matches);
if($find) {
	var_dump($matches);
}

---------- php ----------
array(3) {
  [0]=>
  array(1) {
    [0]=>
    string(33) "<!-- layout::public:index::30 -->"
  }
  [1]=>
  array(1) {
    [0]=>
    string(12) "public:index"
  }
  [2]=>
  array(1) {
    [0]=>
    string(2) "30"
  }
}

输出完成 (耗时 0 秒) - 正常终止
原文地址:https://www.cnblogs.com/phpfans/p/2202362.html