Frage

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

Show "Found0", aber zeige $ match11 nicht. Wie mache ich $ Match 11 zu zeigen? Zurückkehren:

Hinweis: Undefined Offset: 1 in C: xampp htdocs page.php in Zeile 75 Found0: Hinweis: Undefinierter Versatz: 1 in C: xampp htdocs copy page.php in Zeile 75 Found1: Hinweis: Undefinierte Offseton : 1 in C: xampp htdocs copy page.php in Zeile 75 gefunden2:

Entschuldigung, wenn mein Englisch nicht perfekt ist, bin ich kein Eingeborener. :) Danke für Ihre Hilfe.

War es hilfreich?

Lösung

Sie haben vergessen, die () in preg_match () beizulegen:

$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;
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top