Php 我只能使用值预匹配一次
我有一个preg_match命令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
<?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'"));