▼  Site Navigation Main Articles News Search  ▼  Anime + Manga Anime Reviews Anime Characters Gallery Screenshots Manga Reviews  ▼  Misc Links to Webcomics Bible Quotes About Older Musings
site version 7.3
PHP –– functions –– in progress
written by: admin


Date Written: 11/13/09 Last Updated: 1/15/10

Found this from http://ask.metafilter.com/64554/Finding–combinations–in–PHP

<?php
    header('Content-Type: text/plain');
    function showCombinations($string, $traits, $i)
    {
        if ($i >= count($traits))
            echo trim($string) . "\n";
        else
        {
            foreach ($traits[$i] as $trait)
                showCombinations("$string $trait", $traits, $i + 1);
        }
    }
    $traits = array
    (
        array('1'),
        array('2','3'),
        array('3'),
        array('4', '5'),
        array('5')
    );
    showCombinations('', $traits, 0);
?>



TAGS: php
copyright 2005–2024