Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 537 Bytes

contains.md

File metadata and controls

29 lines (21 loc) · 537 Bytes

String contains filter

The contains filter is helpful in reducing the input before sending it to output.

<?php
use ZeroConfig\Cli\Transformer\String\ContainsFilter;

$transformer = new ContainsFilter('bar');
$input       = [
    'This is foo!',
    'Greetings from bar :)',
    'A wonderful day from baz.'
];

foreach ($transformer($input) as $line) {
    echo $line . PHP_EOL;
}

The above example will output:

Greetings from bar :)

Further reading

See other available transformers.