Input type hidden php array

Author: AshiharaAll On: 13.06.2017

I am trying to post an array in a hidden field and want to retrieve that array after submitting form in php.

Passing Array Using Html Form Hidden Element | PHP Programming

A not recommended way to serialize your data but very cheap in performance is to simply use implode on your array to get a string with all values separated by some specified character. On serverside you can retrieve the array with explode then.

But note that you shouldn't use a character for separation that occurs in the array values or then escape it and that you cannot transmit the array keys with this method.

Note that this doesn't transmit array keys. Every of this methods got their own advantages and disadvantages. What you use is mainly depending on how large your array will be, since you should try to send a minimal amount of data with all of this methods.

input type hidden php array

An other way to achieve the same is to store the array in a server side session instead of transmitting it client side. For this have a look at a basic usage example of sessions on php. By posting your answer, you agree to the privacy policy and terms of service.

Stack Overflow Questions Developer Jobs Documentation beta Tags Users. Sign up or log in to customize your list.

php - Passing Array Using Html Form Hidden Element - Stack Overflow

Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us. Log In Sign Up. Join the Stack Overflow Community.

Stack Overflow is a community of 7. Join them; it only takes a minute: Passing Array Using Html Form Hidden Element Ask Question.

So how can i solve it? Shrishail 1 3 7. You need to serialize it in some way.

Shakti Singh 53k 16 94 There are mainly two possible ways to achieve this: Serialize the data in some way: Use the properties of special named input elements: Plyto 8 In Client side use: Kabir Hossain 8 If you want to post an array you must use another notation: Diagboya Ewere 46 5. Sign up or log in StackExchange. Sign up using Facebook. Sign up using Email and Password.

Post as a guest Name.

How to pass php array in input type hidden in html form - Stack Overflow

Stack Overflow works best with JavaScript enabled. MathOverflow Mathematics Cross Validated stats Theoretical Computer Science Physics Chemistry Biology Computer Science Philosophy more 3. Meta Stack Exchange Stack Apps Area 51 Stack Overflow Talent.

inserted by FC2 system