$match_expression = '/<a href="look.php\?id=(.*)" title="Look page: (.*)">(.*)<\/A>/';
  $radompgr =  preg_match_all($match_expression,$q2,$match, PREG_SET_ORDER);
  if($radompgr == TRUE){echo "found $radompgr<br>";}else{echo "not found $radompgr<br>";} //found
for ($i = 0; $i < count($match); $i++) {
  $mathcas = $match[$i][1];
   $radom = preg_match('/[0-9a-z]{39,41}/',$mathcas,$matches2); 
   if($radom == TRUE){
   $match11 = $matches2[1];
   echo "found".$i.": ".$match11."";}else{echo"".$i."not found :(<br>";}
} //  "found0", but don`t show $match11 variable.

显示“找到的0”,但不要显示$ MATCH11。如何进行$匹配11显示?返回:

注意:未定义的偏移量:C: Xampp htdocs htdocs page.php在第75行中找到0:注意:未定义的偏移量:c: xampp htdocs htdocs htdocs copy page page.php。 :1 in c: xampp htdocs copy page pag.php在第75行中找到2:

抱歉,如果我的英语不是完美的,我不是本地人。 :) 谢谢您的帮助。

有帮助吗?

解决方案

您忘记将()封闭在preg_match()中:

$match_expression = '/<a href="look.php\?id=(.*)" title="Look page: (.*)">(.*)<\/A>/';
$radompgr = preg_match_all($match_expression, $q2, $match, PREG_SET_ORDER);

if ($radompgr >= 1)
{
    echo 'found ' . $radompgr;

    for ($i = 0; $i < count($match); $i++)
    {
        $mathcas = $match[$i][1];

        $radom = preg_match('/([0-9a-z]{39,41})/', $mathcas, $matches2);

        if ($radom >= 1)
        {
            $na = $matches2[1];

            echo 'found' . $i . ': ' . $na;
        }

        else
        {
            echo $i . 'not found';
        }
    }
}

else
{
    echo 'not found ' . $radompgr;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top