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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:45:13+00:00 2026-06-13T19:45:13+00:00

Let’s start telling that I’m passing an x amount of variables via post from

  • 0

Let’s start telling that I’m passing an x amount of variables via post from a form.
Let’s name them menu_category_1, menu_category_2, …, menu_category_x, plus, maybe, menu_category_new (I’m using an if empty to check this last one variable).

To make things easier I’m also sending the parameter $key (amount of variables starting from 0).
Now I need to set them into a new variable $menu_category (array), which is going to be imploded and then update my database.

How do I set up that new $menu_category variable to be an array containing all my variables named in the beginning?
I was thinking of using a for loop but I can’t come up with something useful.
Thanks!!!


I ended up going the Quentin way, just adding [] to the keys. I chose this just because it worked right away. However I’m going to dig deeper on janenz00’s sugestion, which I personally think is the way to go.
Thanks to all of you who took the time to go through this!!!!

  • 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-13T19:45:14+00:00Added an answer on June 13, 2026 at 7:45 pm

    Let’s name them menu_category_1, menu_category_2

    You’re using PHP, so let us name them menu_category[0], menu_category[1], etc (or menu_category[], menu_category[], etc) instead.

    Then $_POST['menu_category'] or $_GET['menu_category'] will be an array.

    which is going to be imploded and then update my database

    Normalise your database. Express your one-to-many relationships using a foreign key and a second table, not by storing CSV data.

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

Sidebar

Related Questions

Let's say that I have a html form (actually I have an editor -
Let's say I'm outputting a post title and in our database, it's Hello Y’all
Let me explain best with an example. Say you have node class that can
Let's say that I have a SQLite database that I create in a separate
Let's say after I had login I will be prompt to enter the Name
Let's say, if I need to assign an id to element with first name,
Let's say I have multiple requirements for a password. The first is that the
Let's assume that a user votes for some movies in a scale of 1
Let's say that I have a date in R and it's formatted as follows.
Let's say I have some text as follows: do this, do that, then this,

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.