嘗試捕獲標記之間的所有文本。Php preg_match_all的行爲不如預期
代碼:
$test = '<test>foo<tests> asdlkfjklas lkflsdakj <test>sdfsd<tests> asdlkaskl <test>235234<tests>';
$match = '/<test>(.*)<tests>/';
preg_match_all($match, $test, $nextLink);
的print_r的結果:
Array ([0] => Array ([0] => foo asdlkfjklas lkflsdakj sdfsd asdlkaskl 235234) [1] => Array ([0] => foo asdlkfjklas lkflsdakj sdfsd asdlkaskl 235234))
使用非貪婪定量'' – Barmar
不結果包括所有的'',一切之間''在(*?)? –
Barmar
使用查看源查看它實際返回的內容,因爲瀏覽器隱藏了看起來像HTML標記的內容。 – Barmar