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.

BY Best Interview Question ON 05 May 2020