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

  • Home
  • SEARCH
  • 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 8041771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:20:02+00:00 2026-06-05T04:20:02+00:00

I have string structured like (cat,dog,fish) && (drinks) && (milk,water) I need to convert

  • 0

I have string structured like

(cat,dog,fish) && (drinks) && (milk,water)

I need to convert to an array list like

cat drinks milk
cat drinks water
dog drinks milk
dog drinks water
fish drinks milk
fish drinks water

I’ve thought about doing it with a loop that takes each group and inserts them into an array like

0th pass:
fill the array with the first row

(cat,dog,fish) && (drinks) && (milk,water)

1st pass:
detect the first group and split it while removing the source

cat && (drinks) && (milk,water) 
dog && (drinks) && (milk,water) 
fish && (drinks) && (milk,water)

2nd pass
….

then loop this each time take the line split it add it to the end and remove the original.

Do you have a better idea? and in PHP?

For those who wonder It is part of sentence parsing code I’m writing.

Thanks

  • 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-05T04:20:04+00:00Added an answer on June 5, 2026 at 4:20 am

    Once i needed to make every combination of similar sets. I had a recursive function which was actually very resource-intensive on big array (9 parts containing 5 items each) but i can try to adjust it for you:

    $input=array(array("cat","dog","fish"),array("drinks"),array("milk","water"));
    $output=array();
    function combination($string,$level)
    {
      global $output;
      global $input;
      if (isset($input[$level]))
      {
        $item=$input[$level];
        if (is_array($item))
        {
          foreach ($item as $i)     
            combination($string." ".$i,$level+1);
        }
        else
          combination($string." ".$item,$level+1);
      }
      else
        $output[]=$string;
    }
    combination("",0);
    var_export($output);
    

    However converting your string into input array is different problem, which i am not sure how to solve so i will keep it up to you.

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

Sidebar

Related Questions

I have an array structured like this: {nick, sender, message} arranged into a List<string[]>
Some open source libraries have tendency to re implement basic structures like string, list,
I have a js object structured like: object.property1 = some string; object.property2 = some
If I have a plist which is structured like this: Root Array Item 0
I have a text string structured like this: = Some Heading (1) Some text
I have a string structured like that: BLOCK LIST1 Lorem ipsum dolor sit amet.
I have a class structure like: abstract class A { String a; } class
Say I have a structure like: class SomeObject Public Name as String Public Created
So I have a plist structured string, that get dynamically (not from the file
I have the following class structure: class Organization { string Name; List<User> users; List<Organization>

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.