Skip to content

expand() method

Rieks Visser edited this page Sep 5, 2017 · 2 revisions

Getting paths and their replacements with expand(). The expand method returns a list of paths that match the given pattern and also returns their replacements. The replacement can contain variables in a similar as preg_replace.

<?php
/** @var Mediact\DataContainer\DataContainer $container */
// ['categories.foo' => 'cat.foo']
var_dump($container->expand('categories.f*', 'cat.f$1'));
// ['categories.bar' => 'cat.bar']   
var_dump($container->expand('categories.?a?', 'cat.$1a$2'));
// ['categories.bar' => 'cat.bar']
var_dump($container->expand('categories.ba[zr]', 'cat.ba$2'));
Clone this wiki locally