jaymc Posted October 5, 2007 Share Posted October 5, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/71967-solved-echo-key-with-value/ Share on other sites More sharing options...
MadTechie Posted October 5, 2007 Share Posted October 5, 2007 try this foreach ($_POST as $key => $val) { echo "$key = $val<BR>"; } EDIT: removed an extra} (typo) Quote Link to comment https://forums.phpfreaks.com/topic/71967-solved-echo-key-with-value/#findComment-362484 Share on other sites More sharing options...
jaymc Posted October 5, 2007 Author Share Posted October 5, 2007 Sorry, I had extra code in there but I deleted it as it wasnt relivent to the issue Im having 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>";} } Quote Link to comment https://forums.phpfreaks.com/topic/71967-solved-echo-key-with-value/#findComment-362489 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.