Jump to content

[SOLVED] echo key with value


jaymc

Recommended Posts

I am trying to echo the key name and key value of $_POST

 

I can echo the values fine, but not the key name

 

Heres what I have so far

foreach ($_POST as $val) {

echo "$val<BR>";}

}

 

This is what I want

foreach ($_POST as $val) {

echo "$keyname - $val<BR>";}

}

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/71967-solved-echo-key-with-value/
Share on other sites

Sorry, I had extra code in there but I deleted it as it wasnt relivent to the issue Im having :P

 

The issue was, I wanted $keyname to be the actually keyname of the current key in the loop

 

I've solved it now with this

 

$arrays = array_keys($_POST);

 

foreach ($arrays as $val) {

if ($_POST[$val] > 0) {echo "$val - $_POST[$val]<BR>";}

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.