now we're brave!
[m6w6/ext-pq] / travis / pecl / gen-matrix.php
diff --git a/travis/pecl/gen-matrix.php b/travis/pecl/gen-matrix.php
new file mode 100644 (file)
index 0000000..90e0011
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+
+return function ($array) {
+       foreach ($array as $key => $values) {
+               if (is_numeric($key) && is_string($values)) {
+                       $key = $values;
+                       $values = ["no","yes"];
+               }
+               if (empty($apc)) {
+                       // seed
+                       foreach ($values as $val) {
+                               $apc[] = "$key=$val";
+                       }
+               } else {
+                       // combine
+                       $cpc = $apc;
+                       $apc = [];
+                       foreach ($values as $val) {
+                               foreach ($cpc as $e) {
+                                       $apc[] = "$e $key=$val";
+                               }
+                       }
+               }
+       }
+       return $apc;
+};