Solution 1: Using Regex
You can use a regular expression to strip out single-letter words from a string:
$str = trim(preg_replace('@(^|\pZ)\pL\pM*(?=\pZ|$)@u', ' ', $str));
\pL → matches any letter.
\pM* → matches optional combining marks.
\pZ → matches any separator (like whitespace).
The regex ensures only single-letter words are removed.
If you instead want to remove any single character (not just letters), you can adjust the pattern like this:
$str = trim(preg_replace('@(^|\pZ)\P\Z(?=\pZ|$)@u', ' ', $str));