Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts

    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

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,859
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Check the Example #1 at http://php.net/move_uploaded_file
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    babelfish (03-09-2009)

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts
    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

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,859
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    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
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •