Your Ad Here

Home » PHP Code »

0

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.


You may like these posts

    How to add line breaks in the textareaPHP Charts with using Google APIHow to include external js,css files with javascriptSending mail using phpmailer and gmail as smtp

 

Leave a Reply