ANIL KUMAR PANIGRAHI 's Blog

View more option in simple php

Posted by: Anil Kumar Panigrahi in: ● June 8, 2010

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.

Share on Twitter

No Comments to "View more option in simple php"

Write Comment

About Me

  Anil Kumar Panigrahi
  Software Engineer (PHP)
  Blogger & Founder of Anil Labs
  Baruva, India

You can share with me . . .

My Own Contributions

1) First contribution for codeigniter framework ( multi language support using google translate API ). we can get files from http://github.com/nyros/codeigniter_multilanguage


2) Audio and Video Streaming using FFMpeg and PHP -complete doc file : http://www.docstoc.com/docs/8300349/Audio-and-Video-Streaming

Twitter Updates

Follow me @anil2u
  • http://www.google.co.uk/ logo is changing with mouse move . . . - posted on 07/09/2010 10:57:33
  • True enemies are real friends . . . - posted on 06/09/2010 10:15:29
  • Just watched nice movie " Madrasapattinam ". - posted on 05/09/2010 16:20:48
  • We will always be thankful to our teacher for all the hard work and efforts they have put in, for educating us.- Happy teachers Day . . . :) - posted on 05/09/2010 05:39:13
  • Working on shipping cost functionality (UPS and USPS) for oscommerce shopping cart - posted on 01/09/2010 09:40:03