我想要以下示例的代码....
...示例
$words = "The sculpture was selected during a design competition. After
Kapoor's design was chosen, numerous technological concerns regarding
the design's construction and assembly arose, in addition to concerns
regarding the sculpture's upkeep and maintenance. Various experts were
consulted, some of whom believed the design could not be implemented.
Eventually, a feasible method was found, but the sculpture's construction
fell behind schedule. It was unveiled in an incomplete form during the
Millennium Park grand opening celebration in 2004, before being concealed
again while it was completed. Cloud Gate was formally dedicated on
May 15, 2006, and has since gained considerable popularity, both
domestically and internationally.";
只是我搜索过的文字是“设计一些大公园”
我需要搜索词中的前三十个单词。像谷歌搜索结果页面.....
感谢
答案 0 :(得分:2)
如果你想像真正的搜索引擎一样,你可能会感兴趣Sphinx API。
答案 1 :(得分:1)
使用preg_match_all,最后一个参数根据提供的模式为您提供结果。您可以提供常量字符串而不是正则表达式模式!