Hi friends,

This is very simple post, but usually it will be helpful for freshers( newly learning PHP ) . Suppose we developed a news module in php code.

1) In the home page we have to display some content only.

2) When we click on full view then display the whole content.

For this requirement, follow the below code:

$body = (strlen($content) > 200)? substr($content,0,197). ‘…’ : $content;

This is first check the content length is more than 200 characters then it is display 197 characters and remaining with three dots ( . . . )

Hope that it will be useful.

Categories: PHP Code

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *