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! 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) 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>";} } 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
Archived
This topic is now archived and is closed to further replies.