sineverba
sineverba

Reputation: 5172

array_flip() expects parameter 1 to be array, null given issue

This is my code.

$param = array('email');

$this->getMapper()->copyfrom('POST',function($val) {

    return array_intersect_key($val, array_flip($param));

});

And I get the error in title array_flip() expects parameter 1 to be array, null given issue

If I put directly

return array_intersect_key($val, array_flip(array('email')));

it works.

[Framework is F3, v. 3.5.0].

THank you

Upvotes: 0

Views: 1386

Answers (1)

Volkan Yılmaz
Volkan Yılmaz

Reputation: 639

I think maybe it will work.

$param = array('email');

$this->getMapper()->copyfrom('POST',function($val) use ($param) {

    return array_intersect_key($val, array_flip($param));

});

Upvotes: 4

Related Questions