Peace and Heroism

Peace is boring, war is exciting. If you have any doubt, just look at the entertainment industry, you will find plenty of proofs.

Every one of us wants to a hero. And heroes must defeat villains. So, we create our villains to fight with them, because we need to be the ‘heroes’ at any cost. Heroes love peace, so we have to tell that we love peace, too! Heroes always restore the peace. So, need to restore peace, too! But to ‘restore peace’, we need to ‘destroy peace’ first.

In past days, the chalks had to be white, because the board we used to write on was black. Nowadays, boards have to be white, because now the markers squirt colored ink.

Dear friend, let’s not forget being human in pursuit of being a hero.

How To: Get all PHP $_POST data in an array

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!