Make array from $_POST values

Posted by cbarg on Stack Overflow See other posts from Stack Overflow or by cbarg
Published on 2012-11-04T16:50:19Z Indexed on 2012/11/04 17:00 UTC
Read the original article Hit count: 118

Filed under:
|
|

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!!!

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays