Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7769483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:10:15+00:00 2026-06-01T16:10:15+00:00

i have a code giving me possible combinations, but its missing the combinations of

  • 0

i have a code giving me possible combinations, but its missing the combinations of each array. please let me know how i can generate the combinations of each array as well. like after running stated code i will get possible combinations….but i need the combinations like (rough,medium,small) as well…..

$array1 = array('rough', 'smooth', 'coarse');
$array2 = array('shiny', 'matte', 'rough');
$array3 = array('very large', 'large', 'medium', 'small');

foreach($array1 as $i)
    foreach($array2 as $j)
        foreach($array3 as $k)
            $output[] = "$i, $j, $k";

var_dump($output);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:10:16+00:00Added an answer on June 1, 2026 at 4:10 pm
    $array1 = array('rough', 'smooth', 'coarse');
    $array2 = array('shiny', 'matte', 'rough');
    $array3 = array('very large', 'large', 'medium', 'small');
    
    $array=array_merge($array1,$array2,$array3);
    
    $combinations=array();
    for($x=0;$x<(count($array)-2);$x++) {
        $a=$array[$x];
        for ($y=$x+1;$y<count($array);$y++) {
            $b=$array[$y];
            for ($z=$y+1;$z<count($array);$z++) {
                $c=$array[$z];
                $combinations[]="$a, $b, $c";
            }
        }
    }
    

    This outputs every possible combination of all the values, without repeating any. As shown below:

    Array
    (
        [0] => rough, smooth, coarse
        [1] => rough, smooth, shiny
        [2] => rough, smooth, matte
        [3] => rough, smooth, rough
        [4] => rough, smooth, very large
        [5] => rough, smooth, large
        [6] => rough, smooth, medium
        [7] => rough, smooth, small
        [8] => rough, coarse, shiny
        [9] => rough, coarse, matte
        [10] => rough, coarse, rough
        [11] => rough, coarse, very large
        [12] => rough, coarse, large
        [13] => rough, coarse, medium
        [14] => rough, coarse, small
        [15] => rough, shiny, matte
        [16] => rough, shiny, rough
        [17] => rough, shiny, very large
        [18] => rough, shiny, large
        [19] => rough, shiny, medium
        [20] => rough, shiny, small
        [21] => rough, matte, rough
        [22] => rough, matte, very large
        [23] => rough, matte, large
        [24] => rough, matte, medium
        [25] => rough, matte, small
        [26] => rough, rough, very large
        [27] => rough, rough, large
        [28] => rough, rough, medium
        [29] => rough, rough, small
        [30] => rough, very large, large
        [31] => rough, very large, medium
        [32] => rough, very large, small
        [33] => rough, large, medium
        [34] => rough, large, small
        [35] => rough, medium, small
        [36] => smooth, coarse, shiny
        [37] => smooth, coarse, matte
        [38] => smooth, coarse, rough
        [39] => smooth, coarse, very large
        [40] => smooth, coarse, large
        [41] => smooth, coarse, medium
        [42] => smooth, coarse, small
        [43] => smooth, shiny, matte
        [44] => smooth, shiny, rough
        [45] => smooth, shiny, very large
        [46] => smooth, shiny, large
        [47] => smooth, shiny, medium
        [48] => smooth, shiny, small
        [49] => smooth, matte, rough
        [50] => smooth, matte, very large
        [51] => smooth, matte, large
        [52] => smooth, matte, medium
        [53] => smooth, matte, small
        [54] => smooth, rough, very large
        [55] => smooth, rough, large
        [56] => smooth, rough, medium
        [57] => smooth, rough, small
        [58] => smooth, very large, large
        [59] => smooth, very large, medium
        [60] => smooth, very large, small
        [61] => smooth, large, medium
        [62] => smooth, large, small
        [63] => smooth, medium, small
        [64] => coarse, shiny, matte
        [65] => coarse, shiny, rough
        [66] => coarse, shiny, very large
        [67] => coarse, shiny, large
        [68] => coarse, shiny, medium
        [69] => coarse, shiny, small
        [70] => coarse, matte, rough
        [71] => coarse, matte, very large
        [72] => coarse, matte, large
        [73] => coarse, matte, medium
        [74] => coarse, matte, small
        [75] => coarse, rough, very large
        [76] => coarse, rough, large
        [77] => coarse, rough, medium
        [78] => coarse, rough, small
        [79] => coarse, very large, large
        [80] => coarse, very large, medium
        [81] => coarse, very large, small
        [82] => coarse, large, medium
        [83] => coarse, large, small
        [84] => coarse, medium, small
        [85] => shiny, matte, rough
        [86] => shiny, matte, very large
        [87] => shiny, matte, large
        [88] => shiny, matte, medium
        [89] => shiny, matte, small
        [90] => shiny, rough, very large
        [91] => shiny, rough, large
        [92] => shiny, rough, medium
        [93] => shiny, rough, small
        [94] => shiny, very large, large
        [95] => shiny, very large, medium
        [96] => shiny, very large, small
        [97] => shiny, large, medium
        [98] => shiny, large, small
        [99] => shiny, medium, small
        [100] => matte, rough, very large
        [101] => matte, rough, large
        [102] => matte, rough, medium
        [103] => matte, rough, small
        [104] => matte, very large, large
        [105] => matte, very large, medium
        [106] => matte, very large, small
        [107] => matte, large, medium
        [108] => matte, large, small
        [109] => matte, medium, small
        [110] => rough, very large, large
        [111] => rough, very large, medium
        [112] => rough, very large, small
        [113] => rough, large, medium
        [114] => rough, large, small
        [115] => rough, medium, small
        [116] => very large, large, medium
        [117] => very large, large, small
        [118] => very large, medium, small
        [119] => large, medium, small
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code that is giving me trouble. I know all
I have code that uses jquery.slideup and jquery.slidedown How can i know that div
i have written the following code but it is giving parse error . here
I have the following code which is giving me a Method POST, Status (canceled)
I have five WSDL's that share namespaces, but not all of them. I generate
Possible Duplicate: php headers already sent error I have attached my code which am
I have a query that is giving me problems and I can't understand why
Anyone know why this is happening? In my code I have the following line
I have code that looks like this: template<class T> class list { public: class
I have code that I want to look like this: List<Type> Os; ... foreach

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.