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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:00:59+00:00 2026-06-12T16:00:59+00:00

He stackoverflow, Today I am busy with an function witch get’s all the elements

  • 0

He stackoverflow,

Today I am busy with an function witch get’s all the elements with specific name. Now I have one problem creating this function. The specific name’s are dynamic, so there can be: “conf_1=data&conf_2=data” but also: “conf_1=data&conf_2=data&conf_3=data”

Some code to enlighten you,

foreach($_GET as $key => $value) {
  $a++;
  if (strpos($key, "conf_$a") === 0) {
    $conf[$key] = $value;
  }
}

So lets say we have this URL,

naam=name&dom=domain&id=41&conf_1=data&conf_2=data&conf_3=data&this_1=data&this_2=opt1

Now I am trying to get all the conf elements with the foreach loop but I need the $a parameter to be the 1,2 en 3 numbers. And when I try to take all the this elements $a shut give 1 en 2.

How can I declare that or how can I do this with an different loop. The next step is of-course to put the elements into an array like this:

 $conf = Array
        (
            [1] => data
            [2] => data
            [3] => data
        )

 $this = Array
        (
            [1] => data
            [2] => data
        )

It is important that the numbering is not done automatically. The number in the array shut be the number in the name of the element. Basically conf_1=data has to become [1] => data

I understand that there are multiple ways to do this but I don’ t know witch are the best and the fastest ways. The way I am doing it now is complete wrong:

for($a = 0; $a < 99; $a++){
    // Get all the data
    $conf = array();
    foreach($_GET as $key => $value) {
        if (strpos($key, "conf_$a") === 0) {
            $conf[$key] = $value;
        }
    }

    $finalconf = array();
    //order all data
    $finalconf[$a] = $conf['conf_' . $a];               

    print_r ($conf);
    print_r ($finalconf);
}
  • 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-12T16:01:00+00:00Added an answer on June 12, 2026 at 4:01 pm

    You can try

    $list = array();
    foreach($_GET as $key => $data)
    {
        (strpos($key,"conf_") === 0) AND $list[ltrim(strstr($key,"_"),"_")] = $data ;
    }
    var_dump($list);
    

    Output

    array
      1 => string 'data' (length=4)
      2 => string 'data' (length=4)
      3 => string 'data' (length=4)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, so. I have asked about 5 questions on stackOverflow today, you've all been
Hi Stackoverflow i hope you are all well today, i seem to have run
With help from StackOverflow today, I have gotten my data layer constructed return data
Hey all of you at Stackoverflow. I got this incredibly annoying problem. I try
I encountered with this question today on StackOverflow but didn't get answer. My question
I had one of my colleagues come to me today with a problem of
Hopefully the good people at Stackoverflow can help me today - I basically drank
stackoverflow forum member I am having some problem with a certain report designed using
StackOverflow uses the GZip encoding on all of their pages; the same seems to
Hi Stackoverflow people, I am implementing the MarkerCluster function for google map markers. I

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.