Question


I want to capture all posted data in one single line like name=asd&age=12&city=something and as an array while the data were posted by using form. (I don't wanna capture values like "$name=$_POST['name']")

(Ques-1: as a single line.
Ques-2: as an array.)

How can I do that ?

-Thanks.

Was it helpful?

Solution

I don't quite understand what you want, but I think you're looking for the following:

On a single line:

$raw_data = file_get_contents("php://input");

in an array

$array_data = $_POST // this is already an array?

OTHER TIPS

  1. $postAsLine = file_get_contents("php://input");
  2. $postAsArray = $_POST;

echo $_SERVER['QUERY_STRING'] for current GET query

http_build_query for any array

in your case http_build_query($_POST)

You can use http_build_query($yourKeyValArray) which creates a query string from an array.

it sound like it:

  1. $getAll = serialize($_POST);
  2. $getAsArray = $_POST;

GOOD LUCK

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top