PHP Classes

Smart String: Reformat text string to render within a box

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 94 All time: 9,889 This week: 524Up
Version License PHP version Categories
smart-string 1.0.0The PHP License5PHP 5, Graphics, Text processing
Description 

Author

This class can reformat text string to render within a box.

It can take a given text string and formats it so it can be rendered as graphics that fit within a box of a given width.

The class can use a giver TrueType font to test if the text fits within the given dimensions.

Picture of Roni
  Performance   Level  
Name: Roni is available for providing paid consulting. Contact Roni .
Classes: 12 packages by
Country: Bangladesh Bangladesh
Age: ???
All time rank: 278535 in Bangladesh Bangladesh
Week rank: 214 Up3 in Bangladesh Bangladesh Up
Innovation award
Innovation award
Nominee: 6x

Example

<?php
include_once "lib/SmartString.php";

$text = "I reworked the feed reading signature images I made a while back and added something to trim the strings to a decent length without breaking words. So here you go. A one-liner that will ";

$str = new SmartString("This&nbsp;&nbsp;is &nbsp; &nbsp; a smart string with random words for testing", array(
   
'font_name' => 'arial',
    ));

$str2 = new SmartString($text,array(
   
'line_width'=>45,
));

echo
$str->type('width')->limit(100).PHP_EOL."<br>";
echo
$str2->type('line')->limit(3);


Details

smart-string

Php String Manipulation Class


  Files folder image Files (3)  
File Role Description
Files folder imagelib (1 file)
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (3)  /  lib  
File Role Description
  Plain text file SmartString.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:94
This week:0
All time:9,889
This week:524Up