$_POST -array is an array, like any other array in PHP (besides the so-called superglobal ), so you can pass it as a parameter to a function, pass it and even change it (although in most situations this may be unreasonable).
As for your code, I would modify it a bit to make it more understandable:
PostInfo($_POST); function PostInfo($postVars) { $item1 = $postVars[0]; $item2 = $postVars[1]; $item3 = $postVars[2]; //do something return $result; }
This will explicitly separate the function argument from the $_POST superglobal. Another option would be to simply remove the function argument and rely on the super _ global capabilities of $_POST :
PostInfo(); function PostInfo() { $item1 = $_POST[0]; $item2 = $_POST[1]; $item3 = $_POST[2]; //do something return $result; }
source share