How do you stop hundreds of the same chars without space?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

How do you stop hundreds of the same chars without space?

Post by simonmlewis »

We have an area where people can post comments, but some enter hundreds and hundreds of !!!!! and it forces the admin page to go off the chart.

So can a script operate that stops words of more than x characters wthout spaces?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How do you stop hundreds of the same chars without space

Post by Celauran »

overflow-wrap in CSS might suit your needs.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do you stop hundreds of the same chars without space

Post by simonmlewis »

Mmm it's mre about preventing it than wrapping it.
I want to stop someone posting that sort of spamming rubbish.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How do you stop hundreds of the same chars without space

Post by Celauran »

simonmlewis wrote:So can a script operate that stops words of more than x characters wthout spaces?

Code: Select all

preg_match('/[^\s]{20}/', $string);
will match strings with more than 20 characters without a space, as an example.
Post Reply