64,654
社区成员
发帖
与我相关
我的任务
分享
[User:root Time:17:23:03 Path:/home/liangdong/php]$ php preg.php
123
456
[User:root Time:17:23:04 Path:/home/liangdong/php]$ cat preg.php
<?php
$str = '9kdasf<!--123-->d8asdkM\n<!--456-->addf';
$nmatches = preg_match_all('/<!--(.*)-->/Uis', $str, $matches);
if ($nmatches) {
foreach ($matches[1] as $content) {
echo $content . PHP_EOL;
}
}
?>