Muhammad Shahzad Muhammad Shahzad - 1 year ago 100
PHP Question

php check string has no space and length greater than limit

I have a website where user can add reviews. Now Issue is some user add very lengthy strings and I'm unable to stop them to do that, like a user added a review:


Another user put this review:


Here is code:

if (isset($_POST['addReview'])) {
$summary = isset($_POST['summary']) ? trim($_POST['summary']) : '';

How I can check input string length and make sure there are no reviews like above and input is only words?

Answer Source

A better solution would be to use

word-wrap: break-word;

It will break the string when it gets too long

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download