The $_POST
-array is an array like every other array in PHP (besides being a so-called superglobal), so you can pass it as a function parameter, pass it around and even change it (even though this might not be wise in most situations).
Regarding your code, I'd change it a bit to make it more clear:
PostInfo($_POST);
function PostInfo($postVars)
{
$item1 = $postVars[0];
$item2 = $postVars[1];
$item3 = $postVars[2];
//do something
return $result;
}
This will visibly separate the function argument from the $_POST
superglobal. Another option would be to simple remove the function argument and rely on the superglobal-abilities of $_POST
:
PostInfo();
function PostInfo()
{
$item1 = $_POST[0];
$item2 = $_POST[1];
$item3 = $_POST[2];
//do something
return $result;
}