PHP Classes

PHP Read More: Cut a text to be displayed partially up to a limit

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 102 All time: 9,768 This week: 673Up
Version License PHP version Categories
php-read-more-class 1.0MIT/X Consortium ...5PHP 5, Text processing
Description 

Author

This is a very simple class that can cut a text to be displayed partially up to a limit.

It can take a string, a start position and limit length to cut and returns part of a string if its length exceeds the given limit. Otherwise the class returns the whole string.

Picture of Muhammad Umer Farooq
Name: Muhammad Umer Farooq is available for providing paid consulting. Contact Muhammad Umer Farooq .
Classes: 52 packages by
Country: Pakistan Pakistan
Age: 22
All time rank: 84411 in Pakistan Pakistan
Week rank: 280 Up6 in Pakistan Pakistan Up
Innovation award
Innovation award
Nominee: 6x

Example

<?php
require_once 'classes/ReadMore.php';
$read = new ReadMore;
$text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
   


if(!isset(
$_GET['r'])){
echo
$read->Read(
[
   
'str' => $text,
   
'limit' => 200,
   
'start' => 0,
]
);
$count = $read->CountStr($text);
$limit = 200;
if(
$count >= $limit){
?>
<li><a href="example.php?r=1">Read More</a></li>
<?php }}
if(isset(
$_GET['r'])){
echo
$read->Read(
[
   
'str' => $text,
   
'limit' => $read->CountStr($text),
   
'start' => 0,
]);
}
?>


  Files folder image Files  
File Role Description
Files folder imageclasses (1 file)
Accessible without login Plain text file example.php Example Example script

  Files folder image Files  /  classes  
File Role Description
  Plain text file ReadMore.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:102
This week:0
All time:9,768
This week:673Up
User Comments (2)