X-Git-Url: https://git.m6w6.name/?p=m6w6%2Ftravis-pecl;a=blobdiff_plain;f=gen-matrix.php;h=289209cfc6b716c584e75be3a55e669b95a8795d;hp=90e0011e555457661d1d5c9b1adca8a4ec203c62;hb=HEAD;hpb=3f32c9f45f15e329d1751cdb58cd411a3a5adfcd diff --git a/gen-matrix.php b/gen-matrix.php index 90e0011..289209c 100644 --- a/gen-matrix.php +++ b/gen-matrix.php @@ -1,26 +1,47 @@ $values) { - if (is_numeric($key) && is_string($values)) { - $key = $values; - $values = ["no","yes"]; - } - if (empty($apc)) { - // seed - foreach ($values as $val) { - $apc[] = "$key=$val"; +return function() { + foreach (func_get_args() as $array) { + $apc = []; + foreach ($array as $key => $values) { + if (is_numeric($key) && is_string($values)) { + // switch on yes/no + $key = $values; + $values = ["no", "yes"]; + } else if (is_numeric($key) && is_array($values)) { + // mutually enasbled options + $vpc = []; + foreach ($values as $yes) { + $mpc = "$yes=yes "; + foreach ($values as $no) { + if ($yes === $no) { + continue; + } + $mpc .= "$no=no "; + } + $vpc[] = $mpc; + } + $key = null; + $values = $vpc; } - } else { - // combine - $cpc = $apc; - $apc = []; - foreach ($values as $val) { - foreach ($cpc as $e) { - $apc[] = "$e $key=$val"; + + if (empty($apc)) { + // seed + foreach ((array) $values as $val) { + $apc[] = strlen($key) ? "$key=$val" : $val; + } + } else { + // combine + $cpc = $apc; + $apc = []; + foreach ((array) $values as $val) { + foreach ($cpc as $e) { + $apc[] = strlen($key) ? "$e $key=$val" : "$e $val"; + } } } } + $xpc[] = $apc; } - return $apc; + return $xpc; };