<?php include 'omit.php'; //guess section assert(contSect('this>that|fn|') === 'that|fn|'); assert(contSect('(this>that|fn|)') === 'this>that|fn|'); assert(contSect('this(this|fn|>that|fn|)') === 'this|fn|>that|fn|'); assert(contSect('this(this|fn|+that|fn|)') === 'this|fn|'); assert(contSect('this>that$$') === 'that$$'); assert(contSect('(this>that$$)') === 'this>that$$');
function oFunc($t, $content) { if (oHas($t, '|')) { preg_match_all('/\\|([^\\|]+)\\|/', $t, $funcs); $cs = contSect($t); $out = array_fill(0, sizeof($content), $cs); foreach ($funcs[0] as $func) { $out = array_map(function ($item, $new) use($func) { return str_replace($func, '{' . $new . '}', $item); }, $out, array_map(oGet($func, '\\|', '\\|'), $content)); } return pre($t, $cs) . implode('+', $out) . post($t, $cs); } else { if (oHas($t, '$$')) { $cs = contSect($t); $out = array_fill(0, sizeof($content), $cs); $out = array_map(function ($cont, $tag) { return str_replace('$$', '{' . $cont . '}', $tag); }, $content, $out); return pre($t, $cs) . implode('+', $out) . post($t, $cs); } else { return $t; } } }