Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我只能使用值预匹配一次_Php_Html_Variables_Preg Match - Fatal编程技术网

Php 我只能使用值预匹配一次

Php 我只能使用值预匹配一次,php,html,variables,preg-match,Php,Html,Variables,Preg Match,我有一个preg_match命令 <?php $content = "<span class='hotels'><div id='general_parcel_id'></div></span>"; $wanted=preg_match ('/<span class=\'hotels\'>(.*?)<\/span>/', $content, $result); $resultant = $res

我有一个preg_match命令

<?php
    $content = "<span class='hotels'><div id='general_parcel_id'></div></span>";
    $wanted=preg_match ('/<span class=\'hotels\'>(.*?)<\/span>/', $content, $result);
    $resultant = $result[1];
?>
但这是不可能的。将结果作为变量写入一次。只有一次


提前感谢您……

请您粘贴整个脚本,或者至少粘贴第一节和第二节之间的所有内容。PHP不会取消设置变量,但您可能会遇到范围问题,或者自己意外地重新分配了它。还有,
echo$resultant的输出是什么你不应该使用正则表达式来解析HTML。。。阅读更多内容。@M1ke这是整个脚本。两者之间没有任何区别。echo$resultant的输出=页面上的产品变量(例如:162、163、164等)在每一页上都不同。@M1ke“echo$resultant”提供结果。但是,不能分配给数据库连接中的变量。@Pete不完全匹配
$dbase = mysql_fetch_array(mysql_query("select * from hotex WHERE parcel_id = '$resultant'"));