PHP ~ preg_match() & preg_match_all()

如果想抓取符合條件~不只一次~~~就用 preg_match_all()

preg_match() 會抓到一次後面就不管了~~~~~~張睪說可以用/ig~~~但PHP好像不支援XD

$content = 'abc abc';
preg_match('/abc/', $content, $xx) ;
print_r($xx);

output: Array ( [0] => abc )



$content = 'abc abc';
preg_match_all('/abc/', $content, $xx) ;
print_r($xx);

output : Array ( [0] => Array ( [0] => abc [1] => abc ) )

沒有留言: