大きな文字列を一連の単語で分割したい。
例えば
$splitby = array('these','are','the','words','to','split','by');
$text = 'This is the string which needs to be split by the above words.';
結果は次のようになります。
$text[0]='This is';
$text[1]='string which needs';
$text[2]='be';
$text[3]='above';
$text[4]='.';
これどうやってするの?最善の方法はpreg_split
ありますか、それともより効率的な方法はありますか? 数百 MB のファイルを分割するので、できるだけ高速にしたいと考えています。