php は、文を 1 ~ 3 語で簡単に分解する方法はありますか?
$str = 'Wikipedia was launched on January 15, 2001.';
$str = preg_replace('/[[:punct:]]/i',' ',$str);
$parts = explode(' ',trim($str));
今はこんな言葉を出したい。ありがとう。
$output_array={
"Wikipedia",
"was",
"launched",
"on",
"January",
"15",
"2001", //one word
"Wikipedia was",
"launched on",
"January 15",
"was launched",
"on January",
"15 2001", //two nearby words.
"Wikipedia was launched",
"on January 15",
"was launched on",
"January 15 2001",
"launched on January",
"on January 15" //three nearby words.
}