Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to limit text length in php and provide 'Read more' link
#1
If you have set your php site to display post excerpts on the front or home page, you will want visitors to click on the title or a link to encourage them to continue reading your post or article, right? php makes this technique easy, and customizable.

PHP Code

Code:
<?php
  $string = $profileinfo['description'];
  if (strlen($string) > 150) {
      $stringCut = substr($string, 0, 150);
      $endPoint = strrpos($stringCut, ' ');
      $string = $endPoint? substr($stringCut, 0, $endPoint):substr($stringCut, 0);
      $string .= '... <a style="cursor: pointer;" href="" >Read More</a>';
  }
  echo $string;
?>
To Purchase Credit Click here , For how to make money on Sologet forum Click here . 
There is love in sharing
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  How to Stop Sending E-Mail Spam using PHP mail function Kingsolomon 1 59 11-12-2018, 04:38 PM
Last Post: Solomon
  Multiple file upload in php Kingsolomon 1 67 11-08-2018, 03:01 PM
Last Post: Solomon
  How to read more / hide text using Jquery and PHP Kingsolomon 0 40 10-31-2018, 02:06 PM
Last Post: Kingsolomon
  Download simple HTML email templates Kingsolomon 0 42 10-31-2018, 02:05 PM
Last Post: Kingsolomon
  TIPS How to get Page Loading Time using PHP Kingsolomon 1 77 10-11-2018, 08:29 AM
Last Post: kingugo

Forum Jump:


Users browsing this thread:
1 Guest(s)


Users that viewed this thread:
2 User(s) read this thread:
Alhajimalvjr, Kingsolomon
How to limit text length in php and provide 'Read more' link00