[Solved] How to iterate through all possible combinations in an simple array [closed]


I think this may be what you are looking for?:

<?php
$a[]='cloropil';
$a[]='rodopayta';

    // You first iterate over each
    for($i = 0; $i < count($a); $i++) 
        {
            // As you iterate through the first round, you iterate
            // again to match pairs but include the first iteration
            // value with this second 
            foreach($a as $val) 
                echo $a[$i].'=>'.$val.'<br />';
        }
?>

Gives you:

cloropil=>cloropil
cloropil=>rodopayta
rodopayta=>cloropil
rodopayta=>rodopayta

1

solved How to iterate through all possible combinations in an simple array [closed]