; } +3 ...">

How to print array keys like $ _POST in PHP?

Perhaps the code looks something like this:

foreach(...$POST){
echo $key."<br/>;
}
+3
source share
8 answers
var_dump($_POST);

or

print_r($_POST);

You can insert a preliminary tag before and after for clearer output in your browser:

echo '<pre>';
var_dump($_POST);
echo '</pre>';

And I suggest using Xdebug . It provides an enchanted var_dump that works without prior.

+11
source

See the PHP documentation for foreach: http://php.net/manual/en/control-structures.foreach.php

Your code will look something like this:

foreach ($_POST as $key=>$element) {
   echo $key."<br/>";
}
+3
source

:

echo join('<br />',array_keys($_POST));
+3

- (, ), :

foreach ($_POST as $k => $v) {
  echo $k . "<br>";
}

print_r($_POST);

var_dump($_POST);
+1

, print_r var_dump

0
$array = array_flip($array);
echo implode('any glue between array keys',$array);
0
source

Or you can just print the keys of the array:

foreach (array_keys($_POST) as $key) {
    echo "$key<br/>\n";
}
0
source

Normally I would use print_r($_POST).

If you are using an HTML page, it might be worth wrapping the tag <pre>to get a more convenient output, otherwise useful tabs and line breaks are displayed only in their original form.

print_r () in PHP.net

0
source

Source: https://habr.com/ru/post/1723006/


All Articles