Wondering how to get all PHP $_POST data in an array? Sometimes you may need to get / see the full $_POST (post method data) in order to debug/change PHP code written by someone else. Perhaps a number of conditions work on what data was inserted there from a previous/same page. So, you need to know what data was posted via $_POST method of PHP.

If you know the array keys then you can check them out one by one. But how about if you don’t have any clue? Or want to find out what data was actually posted? Here comes php://input handy.

PHP has a bunch of wrappers. php:// is one of them which gives you access to various I/O streams that PHP uses. php://input is one of them. ( there are a bunch of other streams available too: check out here )

So, here is a code snippet that will output the $_POST data as an associative array:

Now you can debug the code efficiently. Happy coding!

Categories: How-To