dennismonsewicz Posted March 23, 2009 Share Posted March 23, 2009 Is there anyway to grab the particular name of the form where the $_POST variables came from and only display those vals and keys? versus printing out every single $_POST variable? Quote Link to comment https://forums.phpfreaks.com/topic/150775-solved-foreach_post-question/ Share on other sites More sharing options...
Stephen68 Posted March 23, 2009 Share Posted March 23, 2009 Are you submitting more then one form at a time somehow? Quote Link to comment https://forums.phpfreaks.com/topic/150775-solved-foreach_post-question/#findComment-792145 Share on other sites More sharing options...
dennismonsewicz Posted March 23, 2009 Author Share Posted March 23, 2009 no... its the cms system is posting some other information for some odd reason... how would i just strip out the last two entries in the $_POST array? Quote Link to comment https://forums.phpfreaks.com/topic/150775-solved-foreach_post-question/#findComment-792148 Share on other sites More sharing options...
Maq Posted March 23, 2009 Share Posted March 23, 2009 Maybe there is a better way but create a list of POST vars that you want to accept and do a in_array() check in the foreach loop...? I'm not sure how you're deciding what vars you want to keep, with that info there's probably a better solution. Quote Link to comment https://forums.phpfreaks.com/topic/150775-solved-foreach_post-question/#findComment-792149 Share on other sites More sharing options...
dennismonsewicz Posted March 23, 2009 Author Share Posted March 23, 2009 I tried this and its hitting the ELSE statement $array = array('submit-new' => 'submit-new', 'layout' => 'default', 'view' => 'article'); foreach($_POST as $key=>$val) { if(in_array($array, $_POST)) { echo 'nope'; } else { echo $key . ' = ' . $val . '<br/>'; } } Quote Link to comment https://forums.phpfreaks.com/topic/150775-solved-foreach_post-question/#findComment-792152 Share on other sites More sharing options...
kickstart Posted March 23, 2009 Share Posted March 23, 2009 Hi Think using in_array in that way it is looking for that entire array in the $_POST array. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/150775-solved-foreach_post-question/#findComment-792155 Share on other sites More sharing options...
Maq Posted March 23, 2009 Share Posted March 23, 2009 You had some things mixed up, try: $array = array('submit-new' => 'submit-new', 'layout' => 'default', 'view' => 'article'); foreach($_POST as $key=>$val) { if(in_array($key, $array)) { echo $key . ' = ' . $val . ' ';; } else { echo 'nope'; } } Quote Link to comment https://forums.phpfreaks.com/topic/150775-solved-foreach_post-question/#findComment-792156 Share on other sites More sharing options...
dennismonsewicz Posted March 23, 2009 Author Share Posted March 23, 2009 sweet I got things working... Thanks for the help Maq! Here is the working code: $array = array('request_number', 'status' , 'details', 'requestor', 'comments'); foreach($_POST as $key=>$val) { if(in_array($key, $array)) { echo $key . ' = ' . $val . '<br/>'; } else { echo 'nope<br/>'; } } Quote Link to comment https://forums.phpfreaks.com/topic/150775-solved-foreach_post-question/#findComment-792164 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.