preg_match_all没有使用foreach或for

时间:2015-04-24 23:09:01

标签: preg-match-all

这很有用!

preg_match_all('/<script[^>]+src=([\'"])?((?(1).+?|[^\s>]+))(?(1)\1)/', '<script src="brosta/brostapp/assets/global/plugins/bootstrap-datepaginator/bootstrap-datepaginator.min.js" type="text/javascript"></script>', $matches);
print_r ($matches);

但这不是。有什么帮助吗?

$scripts='<script src="brosta/brostapp/assets/global/plugins/bootstrap-datepaginator/bootstrap-datepaginator.min.js" type="text/javascript"></script>|<script src="{$public}/brosta/brostapp/assets/global/plugins/bootstrap-confirmation/bootstrap-confirmation.min.js" type="text/javascript"></script>|<script src="{$public}/brosta/brostapp/assets/global/plugins/bootstrap-confirmation/dffde/bootstrap-confsssirmation.min.js" type="text/javascript"></script>';
$scripts=explode("|", $scripts);
for($i=0;$i<count($scripts);$i++) {
    preg_match_all('/<script[^>]+src=([\'"])?((?(1).+?|[^\s>]+))(?(1)\1)/', $scripts[$i], $matches);
    print_r($matches);
}

0 个答案:

没有答案