Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di agenti
    Registrato dal
    Feb 2002
    Messaggi
    2,427

    regex google translation

    dovrei estrarre del testo dentro questi tag span:

    <span id=result_box class="short_text">
    <span title="il vecchio e il mare" onmouseover="this.style.backgroundColor='#ebeff9'" onmouseout="this.style.backgroundColor='#fff'">
    The Old Man and the Sea
    </span>
    </span>

    con questa non va..

    preg_match_all('/<span id=\"result_box\" >(.*?)>\/<\/span>/', $data, $result, PREG_SET_ORDER);
    2000 post e sono più vecchio di 4 anni...
    grazie a tutti....

  2. #2
    Utente di HTML.it L'avatar di agenti
    Registrato dal
    Feb 2002
    Messaggi
    2,427

    ecco qui

    Meglio così
    codice:
    function get_tag($classe,$stringa) 
    { 
    $pattern = "#<span id=result_box class=\"".$classe."\">(.*?)</span>#";
    preg_match_all($pattern, $stringa, $matches1, PREG_OFFSET_CAPTURE); 
    $test_ok = $matches1[1]; 
    $test_ok = $test_ok[0][0]; 
    //echo var_dump($test_ok);
    
    return strip_tags($test_ok);
    unset($test_ok);
    }
    2000 post e sono più vecchio di 4 anni...
    grazie a tutti....

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.