Dom 多个preg_match打印数组与简单字符串匹配

Dom 多个preg_match打印数组与简单字符串匹配,dom,preg-match,simple-html-dom,Dom,Preg Match,Simple Html Dom,到目前为止,preg_match返回类似数组的结果。如何显示或将其转换为字符串 <?php include('simple_html_dom.php'); $html = file_get_html('URLofPage'); preg_match('/\<h1\>\<span\>(.+)-(.+)\<\/span\>\<\/h1\>/i', $html, $match); var_dump($match

到目前为止,preg_match返回类似数组的结果。如何显示或将其转换为字符串

<?php

    include('simple_html_dom.php');

    $html = file_get_html('URLofPage');

    preg_match('/\<h1\>\<span\>(.+)-(.+)\<\/span\>\<\/h1\>/i', $html, $match);
    var_dump($match);
    $match = $value[1];

    preg_match('/\<div \"comments\"\>(.+)-(.+)\<\/div\>/i', $html, $match);
    var_dump($match);
    $match = $value[1];

?>

返回以下结果:

数组(3){[0]=>字符串(77)” 这是H1 “[1]=>string(32)”这是“[2]=>string(22)”H1”}

到目前为止,我只能得到第一个preg_匹配来查找和显示信息。使用两个preg_匹配可能是不正确的方法。有更好的方法吗?如何将数组转换为简单的字符串,以便用作HTML模板的查找和替换


今年试图提高PHP技能。请提供帮助。

您不应该使用正则表达式来匹配内容,请查看简单html dom页面中的示例,也许您正在寻找
infrade()
function认为str\u get\u html是需要使用的。