method map documentation in bbn\Appui\Option
Applies a function to children of an option
Example
function(callable $f, $id, $deep = false)
{
$opts = \is_array($id) ? $id : ( $deep ? $this->fullTree($id) : $this->fullOptions($id) );
$res = [];
if (\is_array($opts)) {
if (isset($opts['items'])) {
$opts = $opts['items'];
}
foreach ($opts as $i => $o){
$opts[$i] = $f($o);
if ($deep && $opts[$i] && !empty($opts[$i]['items'])) {
$opts[$i]['items'] = $this->map($f, $opts[$i]['items'], 1);
}
if (\is_array($opts[$i])) {
$res[] = $opts[$i];
}
}
}
return $res;
}
Applies a function to children of an option BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2024
BBN Solutions