0
所以,我有一個網站,我直接從另一個相關網站收集數據,以顯示信息。爲此,我正在使用file_get_contents獲取網站,並使用eregi刪除任何不相關的內容。我的問題是,即使我已經通過研究如何將此eregi轉換爲不被棄用的preg_match,我似乎無法找到解決方案。Eregi preg_match轉換
任何人都足夠明白瞭解preg_match的複雜性嗎?
這裏是我當前的代碼:
$content = file_get_contents("http://www.vattenfall.se/sv/teckna- elavtal.htm/papp/mac:24432/ma-vf_se-orderflow/ProductSelection.action?orderMode=true&submitPostalCode=&orderFlow.personal.postalCode=87140&submitPostalCode=Visa+priser");
eregi('<td style="width: 120px;" class="valuePresentation">(.*)</td>', $content, $data);
foreach($data as $split)
{
$split = explode("</td>", $split);
}
這工作得很好 - 但正如我所說,該功能已被棄用,我很想來取代它,如果只有我知道怎麼樣!
在preg_match()只需要在正則表達式模式中添加分隔符 – Winston 2013-02-21 21:35:39
Winston的評論是最好的。在你的情況下,標點符號可能需要被轉義。嘗試:eregi('_