Skip to content

EmanueleCoppola/smartwrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EmanueleCoppola/smartwrap

I wrote this package because I faced the same problem as in this StackOverflow question.

Installation

composer require emanuelecoppola/smartwrap

Usage

use EmanueleCoppola\SmartWrap\SmartWrap;

$sw = new SmartWrap();

$wrapped = $sw->smartwrap('hello! heeeeeeeeeeeeeeereisaverylongword', 20, "\n", true);

print($wrapped);

// Or by using the global function
$wrapped = smartwrap('hello! heeeeeeeeeeeeeeereisaverylongword', 20, "\n", true);

print($wrapped);

Sample input/output

$output = wordwrap('hello! heeeeeeeeeeeeeeereisaverylongword', 20, "\n", true);
// The output will be ↓
$output == "hello!\nheeeeeeeeeeeeeeereis\naverylongword";

$output = smartwrap('hello! heeeeeeeeeeeeeeereisaverylongword', 20, "\n", true);
// The output will be ↓
$output == "hello! heeeeeeeeeeee\neeereisaverylongword";

About

Smarter wordwrap for PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages