emanuelecoppola / smartwrap
Smarter wordwrap for PHP
0.0.2
2020-06-07 15:12 UTC
Requires
- php: ^7.0.0
- ext-mbstring: *
Requires (Dev)
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-11-07 04:53:19 UTC
README
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";