I have a list with all possible combinations. How would I take out a row if there are 3 of the same letters repeated?
Example:
Z4 Z4 G4
Z4 Z4 J1
Z4 Z4 J2
Z4 Z4 J3
Z4 Z4 J4
Z4 Z4 K1
Z4 Z4 Z1 - Remove this
function showCombinations($string, $traits, $i)
{
if ($i >= count($traits))
echo trim($string) . "<br>";
else {
foreach ($traits[$i] as $trait)
showCombinations("$string $trait", $traits, $i + 1);
}
}
$traits = array(array("D1", "D2", "D3", "D4", "F1", "F2", "F3", "F4", "G1", "G2", "G3", "G4", "J1", "J2", "J3", "J4", "K1", "K2", "K3", "K4", "M1", "M2", "M3", "M4", "N1", "N2", "N3", "N4", "P1", "P2", "P3", "P4", "R1", "R2", "R3", "R4", "S1", "S2", "S3", "S4", "T1", "T2", "T3", "T4", "V1", "V2", "V3", "V4", "Z1", "Z2", "Z3", "Z4"), array("D1", "D2", "D3", "D4", "F1", "F2", "F3", "F4", "G1", "G2", "G3", "G4", "J1", "J2", "J3", "J4", "K1", "K2", "K3", "K4", "M1", "M2", "M3", "M4", "N1", "N2", "N3", "N4", "P1", "P2", "P3", "P4", "R1", "R2", "R3", "R4", "S1", "S2", "S3", "S4", "T1", "T2", "T3", "T4", "V1", "V2", "V3", "V4", "Z1", "Z2", "Z3", "Z4"), array("D1", "D2", "D3", "D4", "F1", "F2", "F3", "F4", "G1", "G2", "G3", "G4", "J1", "J2", "J3", "J4", "K1", "K2", "K3", "K4", "M1", "M2", "M3", "M4", "N1", "N2", "N3", "N4", "P1", "P2", "P3", "P4", "R1", "R2", "R3", "R4", "S1", "S2", "S3", "S4", "T1", "T2", "T3", "T4", "V1", "V2", "V3", "V4", "Z1", "Z2", "Z3", "Z4"));
showCombinations('', $traits, 0);