たとえば、次の段落があります
面接を完了する準備ができたら、[面接]をクリックします。心配しないでください、あなたは完全な面接を受ける前に練習する機会があります。休業日は2030年12月30日ですので、必ずご返信ください。お申し込みいただきありがとうございます。
「2030年12月30日」を含む文全体を削除する必要があります。
解決策を提案してください。
これは複数の方法で実行できますが、私はこの方法を使用します。
.
December 30, 2030
存在しないものだけを保持してください。しかし、文の中にある場合、これには問題があります.
。この場合、あなたはお互いにあなたの文章を分離するための別の方法を考える必要があります。
$string = "When you are ready to complete the interview, click Interview me . Don't worry, you will have a chance to practice before you take the full interview. The job closing date is December 30, 2030 so make sure you have your response back to us by then. Thanks for applying.";
$search = "December 30, 2030";
$sentences = explode( '.', $string );
$new_string = '';
foreach ( $sentences as $sentece )
{
if ( !strpos( $sentece, $search ) )
$new_string .= $sentece . '.';
}
出力:
When you are ready to complete the interview, click Interview me . Don't worry, you will have a chance to practice before you take the full interview. Thanks for applying.
最初にそれを文章に分割してみませんか?次に、各文に対してテストを実行し、テストで含める必要があることが示された場合にのみ、それを出力に含めますか?
簡単な解決策は交換です
str_replace('December 30, 2030', '', 'When you are ready to complete the interview, click Interview me . Don't worry, you will have a chance to practice before you take the full interview. The job closing date is December 30, 2030 so make sure you have your response back to us by then. Thanks for applying');
このようにして、現在の日付で変更することもできます。
str_replace('December 30, 2030', date('l jS \of F Y h:i:s A'), 'When you are ready to complete the interview, click Interview me . Don't worry, you will have a chance to practice before you take the full interview. The job closing date is December 30, 2030 so make sure you have your response back to us by then. Thanks for applying');