smith.james0 Posted December 12, 2006 Share Posted December 12, 2006 I have been playing with the $_POST array. I need to get rid of action and submit from the $key. At the moment i use the following codeecho "<table border=\"1\"><tr><td>First array</td><td>Second array</td><td>Sales</td><td>ID</td><td>Units</td><td>ID</td><td>Extra</td>";foreach ($_POST as $key => $book) {if($key == action|| $key == submit)continue;echo "<tr><td>$key</td>";foreach ($book as $key => $value){echo "<td>Key: $key </td><td> Value: $value</td>";}echo "</tr>";}echo"</table><p></p>";It gets rid of the action and submit, BUT it also gets rid of $_POST[0]1 Key: 0 Value: 2a Key: 1 Value: Key: 2 Value:2 Key: 0 Value: 3a Key: 1 Value: Key: 2 Value:3 Key: 0 Value: Key: 1 Value: Key: 2 Value:4 Key: 0 Value: Key: 1 Value: Key: 2 Value:5 Key: 0 Value: Key: 1 Value: Key: 2 Value:6 Key: 0 Value: Key: 1 Value: Key: 2 Value:7 Key: 0 Value: 8a Key: 1 Value: Key: 2 Value:On the left hand it should start 0. If i take the following code outif($key == action|| $key == submit)continue;it starts at zero but includes action and submit.The page is http://xr2.org/fieldnames.phpCan anyone helpMany thanks James Link to comment https://forums.phpfreaks.com/topic/30413-_post-array/ Share on other sites More sharing options...
trq Posted December 12, 2006 Share Posted December 12, 2006 Unless you have defined the constants [i]action[/i] and [i]submit[/i] then the following code means nothing.[code=php:0]if($key == action|| $key == submit)[/code]it should be...[code=php:0]if ($key == "action" || $key == "submit")[/code] Link to comment https://forums.phpfreaks.com/topic/30413-_post-array/#findComment-139977 Share on other sites More sharing options...
smith.james0 Posted December 13, 2006 Author Share Posted December 13, 2006 I have changed that bit of code, but it's still not working correctly.I now have if($key == "submit")continue;if you print the array you get Array( [0] => Array ( [0] => Line 1 [1] => [2] => ) [1] => Array ( [0] => line 2 [1] => [2] => )But the first line still gets lost!First array Second array Sales ID Units ID Extra 1 Key: 0 Value: line 2 Key: 1 Value: Key: 2 Value:Many thanks James Link to comment https://forums.phpfreaks.com/topic/30413-_post-array/#findComment-140297 Share on other sites More sharing options...
smith.james0 Posted December 13, 2006 Author Share Posted December 13, 2006 I have found a solution insted of usingif($key == "submit")continue;useunset($_POST[submit]);James Link to comment https://forums.phpfreaks.com/topic/30413-_post-array/#findComment-140299 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.