2011-06-11 73 views

回答

5

documentation

如果提供的比賽,則充滿了搜索的結果。 $matches[0]將包含匹配完整模式的文本,$matches[1]將具有匹配第一個捕獲的括號內子模式的文本,依此類推。

所以:

$string='this dog is done'; 
preg_match('/^this dog is ([^.]+)/',$string,$m); 
echo $m[1]."\n"; 
相關問題