Pergunta

$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.

Mostrar "Found0", mas não mostre $ Match11. Como fazer $ corresponde 11 para mostrar? Retornar:

AVISO: Offset indefinido: 1 em C: xampp htdocs Page.php na linha 75 Found0: Aviso: Deslocamento indefinido: 1 em C: Xampp htdocs copy página.php na linha 75 Found1: aviso: OFSET REDENSE : 1 em c: xampp htdocs copy page.php na linha 75 Found2:

Desculpe se meu inglês não é perfeito, não sou nativo. :) Obrigado pela ajuda.

Foi útil?

Solução

Você esqueceu de incluir o () em 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;
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top