Automatically compact sequentially-outputted strings that share a common prefix / suffix pair.

v4.0.1 2021-08-04 23:56 UTC

This package is auto-updated.

Last update: 2024-05-04 23:31:29 UTC


WrappedString is a small PHP library for compacting redundant string-wrapping code in text output. The most common use-case is to eliminate redundant runs of HTML open/close tags and JavaScript boilerplate.

Here is how you use it:

use Wikimedia\WrappedString;

$buffer = [
	new WrappedString( '[foo]', '[', ']' ),
	new WrappedString( '[bar]', '[', ']' ),
$output = WrappedString::join( "\n", $buffer );
// Result: '[foobar]'


The project is licensed under the MIT license.