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 7763999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:48:06+00:00 2026-06-01T14:48:06+00:00

Possible Duplicate: PHP take all combinations I’m thinking of making something in PHP that

  • 0

Possible Duplicate:
PHP take all combinations

I’m thinking of making something in PHP that will show me all combinations of license plates.
For example:

You have 3 boxes you can fill in max 2 values

Like

BOX1 BOX2 BOX3
75   PM   M5 
7S   PH   MS
Z5   PN   H5
ZS   RM   HS
25   RH   N5
2S   RN   NS

NOT BOX1+BOX1+BOX1
It needs to show me
ex. 75-PM-M5
ex. 75-PH-MS
ex. 75-PN-MS
ex. 75-PM-H5
ex. 75-PH-H5
ex. 75-PN-H5
So, BOX1+BOX2+BOX3

The PHP script needs to calculate all the combinations for BOX1+BOX2+BOX3
So BOX1 value1 and value2 are ONE value not two separate values. 
In BOX2 value1 and value2 are also ONE value not two separate values and so on.

If I want all combinations of 
BOX1'91' + BOX2'HF' + BOX3'PF'
BOX1'74' + BOX2'RT' + BOX3'YT'

It will calculate an amount of 2x2x2=8 combinations 

ex. 91-HF-PF
ex. 91-HF-YT
ex. 91-RT-PF
ex. 91-RT-YT
ex. 74-HF-PF
ex. 74-HF-YT
ex. 74-RT-PF
ex. 74-RT-YT

Example pincode

you need to enter 4 pincodes to use your apm card

PIN1+PIN2+PIN3+PIN4
1    1    1    1
2    2    2    2
3    3    3    3
4    4    4    4
5    5    5    5
6    6    6    6
7    7    7    7
8    8    8    8
9    9    9    9
0    0    0    0

So you have in total combination of 10x10x10x10=10.000 combinations and it has to show all combinations

if someone could help me out I would be thankful

  • 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-01T14:48:07+00:00Added an answer on June 1, 2026 at 2:48 pm

    Code :

    <?php
    
    function combinations($arr, $n)
    {
        $res = array();
    
        foreach ($arr[$n] as $item)
        {
            if ($n==count($arr)-1)
                $res[]=$item;
            else
            {
                $combs = combinations($arr,$n+1);
    
                foreach ($combs as $comb)
                {
                    $res[] = "$item $comb";
                }
            }
        }
        return $res;
    }
    
    // Your ARRAY (first array is like 'BOX1', etc - )
    // you can put as many items in each 'BOX' as you like... 
    // and as many 'boxes' as you like
    $words = array(array('A','B'),array('C','D'), array('E','F'));
    
    $combos = combinations($words,0);  // ALWAYS, call it with 0 as the last parameter
    print_r($combos);
    
    ?>
    

    Output :

    Array
    (
        [0] => A C E
        [1] => A C F
        [2] => A D E
        [3] => A D F
        [4] => B C E
        [5] => B C F
        [6] => B D E
        [7] => B D F
    )
    

    I think THIS is EXACTLY what you need… 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: php date compare I have a date that I take from the
Possible Duplicate: php regexp: remove all attributes from an html tag $input = '<div
Possible Duplicate: php preg_replace \ I am trying to replace all occurances of the
Possible Duplicate: PHP get all arguments as array? Within a javascript function arguments always
Possible Duplicate: PHP global in functions Using something like this worries me: <? global
Possible Duplicate: Php: remove all tags, but “a href” in a text Is there
Possible Duplicate: PHP 2-way encryption: I need to store passwords that can be retrieved
Possible Duplicate: PHP 2-way encryption: I need to store passwords that can be retrieved
Possible Duplicate: php execute a background process how can I achieve a task that
Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” All of a sudden

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.