Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
単語が 20 文字を超える場合は、文字列から単語を削除する必要があります。私はこれを試しましたが、改行を追加するだけです。
wordwrap($line,30,"",true);
$str = 'asd qqqqqqqqqqqqqqqqq weq'; var_dump(preg_replace('~\b\S{5,}\b~', '', $str));
上記のコードは、5 つの連続した非スペース文字より長いものをすべて削除します。5 を 30 に置き換えると、必要なものが得られます