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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:41:01+00:00 2026-05-27T23:41:01+00:00

I have searched hi and low for a solution. I have a dynamic multidimensional

  • 0

I have searched hi and low for a solution. I have a dynamic multidimensional array I need to break up and urlencode. The number of items will change but they will always have the same keys.

$formFields = Array ( 
[0] => Array ( [form_name] => productID [form_value] => 13 ) 
[1] => Array ( [form_name] => campaign [form_value] => email@gmail.com ) 
[2] => Array ( [form_name] => redirect [form_value] => http://example.com ) ) 

Each array has a Form Name and a Form Value.

This is what I’m trying to get to:

$desired_results = 
productID => 13
campaign => email@gmail.com
redirect => http://example.com

Every time I try and split them up I end up with: form_name => productID or something like that.

I’m trying to take the results and then urlencode them:

productID=13&campaign=email&gmail.com&redirect=http://example.com&
  • 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-05-27T23:41:02+00:00Added an answer on May 27, 2026 at 11:41 pm

    This will return the values regardless of the names of the keys.

    $result = array();
    
    foreach ($formFields as $key => $value)
    {
      $tmp = array_values($value);
      $result[$tmp[0]] = $tmp[1];
    }
    print(http_build_query($result));
    

    The foreach loops through the main array, storing the subarrrays in the variable $value. The function array_values return all the values from each array as a new numeric array. The value of [form_name] will be stored in the first index, [form_value] in the second.

    The built in http_build_query function will return a urlencoded string.

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

Sidebar

Related Questions

I have searched high and low for this solution. Any insights will be highly
I have searched high and low for a solution but I dont seem to
I have searched but apparently my google foo is weak. What I need is
I have searched the knowledge base high and low, but nothing seems to give
I have searched hi and low for a solution for this, basicly I would
I've searched high and low, but I could not find a solution, to what
I have searched high and low, but I can't figure this one out. I
I have searched high and low for a solution. I have both linecache19 and
I have searched high and low, but have found very little to achieve my
I have searched high and low (and very possibly could have missed it), but

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.