Skip to content

String Functions

All functions below are in the Cline\fp namespace.

Explode a piped string using $delimiter.

use function Cline\fp\explode;
$words = pipe("Hello World",
explode(' ')
);
// $words is ['Hello', 'World']

Implode a piped array using $glue.

use function Cline\fp\implode;
$sentence = pipe(['Hello', 'World'],
implode(' ')
);
// $sentence is 'Hello World'

replace(array|string $find, array|string $replace)

Section titled “replace(array|string $find, array|string $replace)”

Does a find/replace in a piped string, using str_replace().

use function Cline\fp\replace;
$result = pipe("Hello World",
replace('World', 'PHP')
);
// $result is 'Hello PHP'