1.

How to limit string length in php?

Answer»

To limit the characters in a PHP string, use the following code:

if (strlen($STR) > 10)
    $str = substr($str, 0, 6) . '...';

In the above code, if the str value is greater than 10, the OUTPUT will display the final result from 0 to the 6TH character of the said string.



Discussion

No Comment Found