if string more than 50 characters add … by PHP

If you want to show… if string more than 50 characters, follow these steps:if string more than 50 characters add by PHP



If you have sample string content, like this:

$in = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";


Just put the following code in your PHP support code file:

echo $out = strlen($in) > 50 ? substr($in,0,50)."..." : $in;


Now your result is look like this:
Lorem ipsum dolor sit amet, consectetur adipisicin...

if string more than 50 characters add by PHPexpoundsofttechsolution

ghb