emeraldion/tramezzino

Converts a list of strings into a compact, readable representation with delimiters of choice

dev-master 2023-07-04 23:17 UTC

This package is auto-updated.

Last update: 2024-05-05 00:59:31 UTC


README

Build Status Coverage Status Latest Unstable Version composer.lock Total Downloads Monthly Downloads

tramezzino

Converts a list of strings into a compact, readable representation with delimiters of choice

tramezzino.php 'alba,albero,albergo,alberto'
# => alb(a|er(go|o|to))

tramezzino.php 'aria:arianna' ':' '[' '+' ']'
# => aria[+nna]

What?

In Italian, tramezzino means sandwich. The name hints at the strings being sliced and interleaved with bread, the delimiters. Tramezzino is the PHP port of the Node module sarnie.

Why?

Useful when you need to pass long lists of URL params

Composer

Add it to your PHP project using Composer:

composer require emeraldion/tramezzino

Then have it your way:

<?php
use Emeraldion\Tramezzino\Tramezzino;

$encoded = Tramezzino::encode(array('alba', 'albero', 'albergo', 'alberto'), '(', '|', ')');
// $encoded == 'alb(a|er(go|o|to))'
?>

License

MIT

Copyright (c) 2017-2023, Claudio Procida