ファイルをフェッチする配列を作成し、そのファイルの内容を解析しました。私はすでに4文字未満の単語を除外しましたif(strlen($value) < 4): unset($content[$key]); endif;
私の質問はこれです-私は配列から一般的な単語を削除したいのですが、それらのかなりの数があります。これらのチェックを各配列値に対して何度も繰り返す代わりに、これを行うためのより効率的な方法があるかどうか疑問に思いました。
これが私が現在使用しているコードのサンプルです。このリストは膨大になる可能性があり、より良い(より効率的な)方法が必要だと思いますか?
foreach ($content as $key=>$value) {
if(strlen($value) < 4): unset($content[$key]); endif;
if($value == 'that'): unset($content[$key]); endif;
if($value == 'have'): unset($content[$key]); endif;
if($value == 'with'): unset($content[$key]); endif;
if($value == 'this'): unset($content[$key]); endif;
if($value == 'your'): unset($content[$key]); endif;
if($value == 'will'): unset($content[$key]); endif;
if($value == 'they'): unset($content[$key]); endif;
if($value == 'from'): unset($content[$key]); endif;
if($value == 'when'): unset($content[$key]); endif;
if($value == 'then'): unset($content[$key]); endif;
if($value == 'than'): unset($content[$key]); endif;
if($value == 'into'): unset($content[$key]); endif;
}