Solved

php array from input hidden

Posted on 2004-08-25
4
267 Views
Last Modified: 2010-05-18
Is it possible to grab a bunch of values from an html page, put them in a hidden,
and then have a php script process the value of the hidden like

foreach ($hiddenArray as $var) {

}
0
Comment
Question by:warrenlyle
  • 3
4 Comments
 
LVL 27

Expert Comment

by:Diablo84
Comment Utility
if you had multiple hidden fields they would each have to be called name[]

example

<input type="hidden" name="iput[]" value="something">
<input type="hidden" name="iput[]" value="something else">
<input type="hidden" name="iput[]" value="another thing">
<input type="hidden" name="iput[]" value="one more thing">

then on the processing page

$hiddenArray = $_POST['iput'];

foreach ($hiddenArray as $var) {
 //do something with each value
}
0
 
LVL 27

Accepted Solution

by:
Diablo84 earned 500 total points
Comment Utility
if you wanted them all in one hidden field, which may for example look like this

<input type="hidden" name="iput" value="something,something else,another thing,one more thing">

you would then do

$hiddenArray = $_POST['iput'];

$components = explode(",",$hiddenArray); //where as , is the string seperator, you could of course use something else like |

foreach ($components as $var) {
 //do something with each value
}
0
 

Author Comment

by:warrenlyle
Comment Utility
thanks!!
0
 
LVL 27

Expert Comment

by:Diablo84
Comment Utility
no problem :)

|)iablo
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now