Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-09-2009, 04:06 PM   PM User | #1
babelfish
Regular Coder

 
Join Date: Jun 2002
Location: England =)
Posts: 518
Thanks: 25
Thanked 0 Times in 0 Posts
babelfish can only hope to improve
need advice - vars from $_POST array???

Hi all,

ok, not sure on how to ask this one.....but here goes!

im writing an app that needs to read all the pdf files from a directory, then create a checklist of the items, that a user will select. it will then (eventually) create a pdf file from these pdf files and store it somewhere.

i have got the read from dir working, the issue i have at the moment is that as i dont know how many files will be found i have an unknown number of $_POST variables returned.

is there an easy way to loop through this array and take out the info?

normally i always know $_POST vars so i can just do $varname = $_POST['varname'], but this time its just something like:

[filename1] => Adhesive_Flooring_Method.pdf
[filename2] => Ceramic Tiling Method Statement.pdf
[filename3] => ceramic tiling to walls and columns Method Statement.pdf
[filename4] => Delmar_Method_Gyplyner_Flooring.pdf
[filename5] => grinding and sharpening blades - method statement.pdf

any help appreciated!
__________________
"They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson
babelfish is offline   Reply With Quote
Old 03-09-2009, 04:22 PM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Check the Example #1 at http://php.net/move_uploaded_file
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Users who have thanked abduraooft for this post:
babelfish (03-09-2009)
Old 03-09-2009, 04:36 PM   PM User | #3
babelfish
Regular Coder

 
Join Date: Jun 2002
Location: England =)
Posts: 518
Thanks: 25
Thanked 0 Times in 0 Posts
babelfish can only hope to improve
not sure you got what i meant. i know how to do the file manipulation bit. BUT i did get the answer i needed from that code.

Code:
	foreach ($_POST as $key => $error) {
		  echo $_POST[$key] . "<br />\n";
	}
im just not sure how the '$key => $error' works though. or am i even doing this right. basically i need the posted values but never knew the $_POST['varname'] part as this was all done dynamically.
__________________
"They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson
babelfish is offline   Reply With Quote
Old 03-09-2009, 04:40 PM   PM User | #4
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
I think I misread your post. So you need to extract the values in your POST array and assign them to their respective simple variables?
PHP Code:
foreach($_POST as $key=>$value){
 $
$key=$value;

See http://php.net/language.variables.variable
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 03-09-2009, 04:48 PM   PM User | #5
babelfish
Regular Coder

 
Join Date: Jun 2002
Location: England =)
Posts: 518
Thanks: 25
Thanked 0 Times in 0 Posts
babelfish can only hope to improve
Smile

you are a star mate - thanks

i guess i should have always done this rather than the masses of $varname = $_POST[varname']; eh?

really should read that manual at some point! but you know, time is precious and all that!

thanks again mate!
__________________
"They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson
babelfish is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:25 PM.


Advertisement
Log in to turn off these ads.