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 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2003
    Posts
    87
    Thanks
    0
    Thanked 1 Time in 1 Post

    Help with FOREACH... with an example

    Ok, it must be that I am tired as I can not figure out the simple thing that I have done so many times. FOREACH.

    In my simple example, all I want is to print out all the values from the array.

    Code:
    <form action="testarray.php" method="post">
    <input type="text" name="toolname[]"><br />
    <input type="text" name="toolname[]"><br />
    <input type="text" name="toolname[]">
    <input type="submit" name="submit" value="submit"></form>
    
    
    PHP Code:
    $toolname $_POST['toolname']; print_r($toolname);   foreach ($toolname as $value) { echo '<p>' $toolname[$value] . '</p>'
    The Array prints out fine but the foreach part doesn't work...

    And I have no idea why my php code appears on one long line in this post, sorry.
    Neno

  • #2
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    PHP Code:
    $toolname $_POST['toolname'];
    print_r($toolname);
    foreach (
    $toolname as $value
    {
       echo 
    '<p>' $value '</p>';


  • #3
    New Coder
    Join Date
    Aug 2003
    Posts
    87
    Thanks
    0
    Thanked 1 Time in 1 Post
    LOL, I knew it was something real stupid that I overlooked. Oh well... told you I was tired.

    Thanks a lot.
    Neno


  •  

    Posting Permissions

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