phpfat-free-frameworkarray-flip

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


Solution

  • 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));
    
    });