Page 1 of 1

#_POST key/value question. [SOLVED]

Posted: Sun Jan 02, 2011 11:02 pm
by spedula
Is there a way to access $_POST values without knowing the key?

For Example:

Code: Select all


for ($i = 0; $i < count($_POST); $i++) {
   echo $_POST[$i].'<br>';
}

I managed to find something that kind of works but if the post value itself is an array, it just saves it as a string, "Array", and not the values inside that array. I need to be able to preserve the value if it's an array as well.

Code: Select all



if ($_POST) {
  $postKeys = array();
  $postVals = array();
  foreach ($_POST as $k => $v) {
    $postKeys[] = "$k";
    $postVals[] = "$v";
  }
}


Re: #_POST key/value question.

Posted: Sun Jan 02, 2011 11:28 pm
by spedula
Found the answer myself.

Code: Select all


$form_values = array_values($_POST);

That will store all the $_POST associated array values as numerical array values.