Try this code for following Pupose
you can adjust number of character i mean if you need to show only 20 character then need to change 50 to 20
Here are two method which one you understand just use them in your code
<?php
$in=”Pellentesque habitant morbi tristique senectus eter netus et malesuada fames ac turpis egestas. Morbi purus nisl, blandit et eros id, pharetra tristique massa. Nulla facilisi. Curabitur lobortis urna eu neque congue, id cursus purus placerat. In malesuada est tellus. Nunc ac ullamcorper nibh. Maecenas lacus dolor, volutpat sed augue sit amet, maximus condimentum sem. Aenean nec egestas orci. Sed fringilla augue eget arcu consectetur interdum. Praesent sed dignissim risus. Ut lobortis dolor nec sagittis dapibus. Donec eget dolor vitae elit porta commodo in et magna. Nunc sapien nisl, euismod ac ex vitae, sodales feugiat lorem. Phasellus condimentum, nulla cursus porta mollis, nulla urna dapibus velit, vitae sagittis arcu risus vitae orci. Praesent leo nisi, laoreet id mauris nec, hendrerit feugiat lacus. Praesent vulputate lorem vel lobortis aliquam.”;
?>
Method:1
<?= $out = strlen($in) > 50 ? substr($in,0,50)."..." : $in;?>
Method:2
$result = substr($in, 0, 50); //first 50 chars “Pellentesque habitant morbi tristique senectus eter”
Just use below code and modified according to your need. Note: this is very useful…