// 匹配含有hi的单词 计算有多少个含有hi单词
$str = 'hi his is this history sthisdd';
$patt = '/hi/';
preg_match_all($patt,$str,$src);
var_dump($src);
/*
array (size=1)
0 =>
array (size=5)
0 => string 'hi' (length=2)
1 => string 'hi' (length=2)
2 => string 'hi' (length=2)
3 => string 'hi' (length=2)
4 => string 'hi' (length=2)
*/