Forum Moderators: coopster
IE:
$words1 = "1
2
3
4";
$words2 = "a
b
c
d";
$words3 = "x
y
z";
The Output is:
1
1a
1ax
1b
1bx
etc...
I want to add some options where if a condition is true, then it will only output data that has a combination from all 3 arrays OR at least 2 arrays OR all possible combinations.
Basically I'm trying to setup it up so I can have the function only output "1ax" but NOT "1" - or "1b" AND "1ax" but NOT "1"...
Here is my logic:
if ($all3 == 1) {
output all possible combinations (code below)
}
if ($min3 == 1) {
output all combinations that have data from each of the 3 arrays;
}
if ($min2 == 1) {
output all combinations that have data from at least 2 of the arrays
}
$words1 = array();
$words2 = array();
$words3 = array();$words1 = explode("\n", $_POST['list_a']);
$words2 = explode("\n", $_POST['list_b']);
$words3 = explode("\n", $_POST['list_c']);$combinations = array();
foreach ($words1 as $word1)
{
foreach ($words2 as $word2)
{
foreach ($words3 as $word3)
{
$combinations[] = trim($word1) . ' ' . trim($word3);
$combinations[] = trim($word1) . ' ' . trim($word2) . ' ' . trim($word3);
}
Can anyone tell me how I can modify this code to accomplish that?
Thanks!