Lodius2000 Posted November 22, 2008 Share Posted November 22, 2008 this is a followup to my last topic, which was solved http://www.phpfreaks.com/forums/index.php/topic,226621.0.html but now the topic has changes enough to warrant a new topic and a repost of my last post in the previous topic, which contains the question I wanted to ask here so I want to split apart my post array so i can query the db post looks like this $_POST[1]['word'] $_POST[1]['replace'] $_POST[2]['word'] $_POST[2]['replace'] where the integer is a row number so to split it apart i use <?php foreach ($_POST[] as $word, $replace){ mysql_query("UPDATE badwords SET word = $word WHERE id={$_POST['id']}"); //repeat for replace } ?> is that right? thanks Quote Link to comment https://forums.phpfreaks.com/topic/133742-retrieving-values-from-nested-post-array/ Share on other sites More sharing options...
genericnumber1 Posted November 22, 2008 Share Posted November 22, 2008 <?php foreach($_POST as $param) { $param['word']; // word $param['replace']; // replace } ?> Quote Link to comment https://forums.phpfreaks.com/topic/133742-retrieving-values-from-nested-post-array/#findComment-695987 Share on other sites More sharing options...
Lodius2000 Posted November 22, 2008 Author Share Posted November 22, 2008 so generic, where does my id number go, if $_POST[1]['word'] i can now retrieve $word but ive lost '1' thanks Quote Link to comment https://forums.phpfreaks.com/topic/133742-retrieving-values-from-nested-post-array/#findComment-695992 Share on other sites More sharing options...
genericnumber1 Posted November 22, 2008 Share Posted November 22, 2008 Yes, you lose the number, if you want to preserve the number you can do <?php foreach($_POST as $id => $param) { $id; // id number $param['word']; // word $param['replace']; // replace } ?> Quote Link to comment https://forums.phpfreaks.com/topic/133742-retrieving-values-from-nested-post-array/#findComment-695996 Share on other sites More sharing options...
Lodius2000 Posted November 22, 2008 Author Share Posted November 22, 2008 awesome thanks Quote Link to comment https://forums.phpfreaks.com/topic/133742-retrieving-values-from-nested-post-array/#findComment-696000 Share on other sites More sharing options...
.josh Posted November 22, 2008 Share Posted November 22, 2008 Reading the foreach entry in the manual could have solved your problem just as easily, if not quicker... Quote Link to comment https://forums.phpfreaks.com/topic/133742-retrieving-values-from-nested-post-array/#findComment-696005 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.