Combinations using PHP Arrays
Posted: Thu May 10, 2007 11:55 pm
Weirdan | Please use
Weirdan | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I need a quick and simple solution for my query. I have a set of array, each index has another array with a set of elements. I need to generate the common possible combinations ouptput like given below.
Pls Help. Thx in Advance
SriniCode: Select all
<?
//given array
$x[0] = array(1,3,5);
$x[1] = array(6,7);
$x[3] = array(8,10,12);
//desired ouptput
$z[] = "1,6,8";
$z[] = "1,6,10";
$z[] = "1,6,12";
$z[] = "1,7,8";
$z[] = "1,7,10";
$z[] = "1,7,12";
$z[] = "3,6,8";
$z[] = "3,6,10";
$z[] = "3,6,12";
$z[] = "3,7,8";
$z[] = "3,7,10";
$z[] = "3,7,12";
$z[] = "5,6,8";
$z[] = "5,6,10";
$z[] = "5,6,12";
$z[] = "5,7,8";
$z[] = "5,7,10";
$z[] = "5,7,12";
?>Weirdan | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]