我是一個noob,當涉及到正則表達式,而不是用php也不好。pre_match div與不必要的換行符
我用這個代碼從另一個URL複製內容:
<?php
$conts = file_get_contents('http://www.curtisjohnsonrealtyaz.com');
$pattern = '~<div.*id="home-right".*>(.*?)</div>~iUs';
preg_match($pattern, $conts, $matches);
array_shift($matches);
echo $matches[0];
?>
它的工作除了額外的換行符罰款,還更換了一個錨定的圖像鏈接到當前的URL。
我真的很感謝一些幫助。
感謝
「它的工作除了額外的換行符罰款,還更換了一個錨定的圖像鏈接到當前的URL 「。 我不確定這是什麼意思。 – Ciaran 2011-03-24 08:30:39