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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:24:02+00:00 2026-06-12T20:24:02+00:00

I have an array that looks like this mainArray => [a] => [A] [B]

  • 0

I have an array that looks like this

mainArray =>
    [a] =>
        [A]
        [B]
        [C]
    [b] =>
        [D]
        [E]
        [F]
    [c] =>
        [G]
        [H]
        [I]

I want to put these into an array like this:

secondArray =>
    [0] => { [A], [D], [G] }
    [1] => { [A], [E], [G] }
            .
            .
            .
    [n] => { [C], [F], [I] }

I am having trouble figuring out how to get the right number of elements in $secondArray that start with a certain element in { [A],[B], .. }. For example, how many start with [A].

This is what I think I have to do:

secondArray =>
   [0] =>
        [A]

secondArray =>
   [0] =>
        [A]
        [D]

secondArray =>
   [0] =>
        [A]
        [D]
        [G]


secondArray =>
   [0] =>
        [A]
        [D]
        [G]
   [1] =>
        [A]
        [D]
        [H]


secondArray =>
   [0] =>
        [A]
        [D]
        [G]
   [1] =>
        [A]
        [D]
        [H]
   [2] =>
        [A]
        [D]
        [I]

secondArray =>
   [0] =>
        [A]
        [D]
        [G]
   [1] =>
        [A]
        [D]
        [H]
   [2] =>
        [A]
        [D]
        [I]
   [3] =>
        [A]
        [E]
        [G]
   [4] =>
        [A]
        [E]
        [H]
   [5] =>
        [A]
        [E]
        [I]

secondArray =>
   [0] =>
        [A]
        [D]
        [G]
   [1] =>
        [A]
        [D]
        [H]
   [2] =>
        [A]
        [D]
        [I]
   [3] =>
        [A]
        [E]
        [G]
   [4] =>
        [A]
        [E]
        [H]
   [5] =>
        [A]
        [E]
        [I]
   [6] =>
        [A]
        [F]
        [G]
   [7] =>
        [A]
        [F]
        [H]
   [8] =>
        [A]
        [F]
        [I]

and so on, but I can’t really think of how to implement it…

Any help would be appreciated

  • 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-12T20:24:04+00:00Added an answer on June 12, 2026 at 8:24 pm

    You can generate the elements sequentially.

    To implement the iterator:

    -remember the array of input arrays, if there exists a next element.
       and an array of indexes of the same length.
    -if any input array is empty, the result set is empty and there is no next (first) element.
    -initialise the array of indexes to all zeroes.
    
    To get the next element:
    -If you remember there is no next element, fail.
    -compute the result:
    --start with an empty result
    --For each input array and its corresponding index
    ---Append input[index] to the result
    -compute the next set of indexes:
    --Iterate the indexes in reverse order. For each index
    ---Increment the index
    ---If the index now points past its corresponding input array
    ----Reset the index to zero
    ---Else
    ----Return the result, exiting the function.
    -Remember there is no next element
    -Return the result (last element).
    

    If you do want all combinations at once, the code simplifies slightly:

    -if any input array is empty, the result set is empty.
    -initialise the array of indexes to all zeroes.
    -compute the result and store in the result set.
    -while not done generating results:
    --Iterate the indexes in reverse order. For each index
    ---Increment the index
    ---If the index now points past its corresponding input array
    ----Reset the index to zero
    ---Else
    ----Compute the result from the current indexes
    ----Add the result to the result set
    ----Continue generating the results
    --(all indexes were reset to zero) finish generating the results.
    -return the result set.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Array that looks like this [[BR,1],[USA,2],[CH,3]] and I want to convert
I have an array in ASP that looks like this: 3,5,7,7,3,2,3 What I want
I have an array that looks like this: [ Object actions: Array[2] comments: Object
I have a array that looks like this Array ( [provider] => Array (
I have an array that looks like this: Array ( [0] => Array (
I have an array that looks like this, Array ( [0] => 849710414 [1]
I have an Array that looks like this: array( 0 => array( 'key1' =>
I have an array that looks like this (sample): Array ( [1600] => Array
I have an array that looks like this Array ( [0] => Array (
Hi I have an array that looks like this : Array ( [0] =>

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.