I need to remove words from string, if they're longer than 20 characters. I've tried this but it only adds line breaks.
wordwrap($line,30,"",true);
I need to remove words from string, if they're longer than 20 characters. I've tried this but it only adds line breaks.
wordwrap($line,30,"",true);
$str = 'asd qqqqqqqqqqqqqqqqq weq';
var_dump(preg_replace('~\b\S{5,}\b~', '', $str));
The code above removes everything longer than 5 consecutive non-space characters. Replace 5 with 30 and you'll get what you want