2009-08-13 15 views
1
$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. 

Zeigen Sie "found0", aber zeigen Sie $ match11 nicht. Wie $ 11 zu zeigen, um zu zeigen? Return:preg_match in preg_match_all

Hinweis: Offset Nicht definiert: 1 in C: \ xampp \ htdocs \ page.php on line 75 found0: Hinweis: Undefined offset: 1 in C: \ xampp \ htdocs \ copy \ page .php on line 75 found1: Hinweis: Undefined offset: 1 in C: \ xampp \ htdocs \ copy \ page.php on line 75 found2:

Sorry, wenn mein Englisch ist nicht perfekt, ich Ich bin kein Einheimischer. :) Vielen Dank für Ihre Hilfe.

+0

Was die * ist Frage *? – chaos

+0

Schwer zu beantworten, ohne richtige Frage und hässliche Codeformatierung. –

Antwort

3

Sie haben vergessen, die() in preg_match() zu umschließen:

$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; 
}