• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

foreach: showing name AND value

Hello,

The problem with this is that it ONLY shows the value.

      foreach ($_POST as &$key) {
      echo $key ."/n";
      }

I want to ALSO show the name of the post value.

If this is in my form:
  <input type="hidden" name="food" value="apple" />

Then I want this to be returned:

      food: apple

NOT just "apple"


I use PHP5
0
hankknight
Asked:
hankknight
1 Solution
 
glcumminsCommented:
foreach ($_POST as $key=>$value)
{
  ...
}
0
 
MikkkCommented:
foreach (array_keys($_POST) as &$key) {
      echo $key ."/n";
      echo $_POST[$key]."/n";
      }
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now