-4
$item_list = request_array($item);
print_r($item_list);

This prints out:

Array ( [7] => dmulder ) Array ( [7] => blah ) Array ( [7] => wef ) Array ( [7] => ) Array ( [7] => ) Array ( [7] => ) Array ( [7] => ) Array ( [7] => )

All of the values are indexed 7. Anyone know what causes this?

This is request_array:

function request_array($varname) {
    if (!empty($_REQUEST[$varname])) {
        return (array) $_REQUEST[$varname];
    } else {
        return array();
    }
}
10
  • 2
    That's not a standard PHP function. What's its code look like? Commented Nov 3, 2011 at 19:41
  • Which function? request_array? Commented Nov 3, 2011 at 19:41
  • Didn't realize that. Someone on my team must have written it. Let me find it. Commented Nov 3, 2011 at 19:42
  • 1
    In addition, you're getting back an array of arrays.... it is impossible to have an array with several elements having the same key. Commented Nov 3, 2011 at 19:43
  • 1
    Now if that isn't the stupidest bit of code... Should be on TDWTF. $_REQUEST is a superglobal and is ALWAYS present, even if just as an empty array. Commented Nov 3, 2011 at 19:47

1 Answer 1

0

It may solve ur problem....

function request_array($varname) {
    if (!empty($_REQUEST[$varname])) {
        return $_REQUEST[$varname];
    } else {
       return array();
    }
}

The type-custing is not necessary here...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.