Jump to content

permutations of a multi-dimensional array


centenial

Recommended Posts

Here's a quick and dirty solution.

 

<?php

$data = array ('s', 't', 'r', '1', '2', '3');

foreach($data as $char1)
{
    foreach($data as $char2)
    {
        if ($char2 != $char1)
        {
            foreach($data as $char3)
            {
                if ($char3!=$char1 && $char3!=$char2)
                {
                    echo "{$char1}{$char2}{$char3}<br />\n";
                }
            }
        }
    }
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.