Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The usual solution is to wrap it with a closure.

    function($x) { return array_key_exists('needle', $x); }
Or using the arrow function syntax:

    fn($x) => array_key_exists('needle', $x)
The same trick also helps when you need to use functions with mandatory extra parameters, functions with pass-by-value parameters, etc.


If the Partial Function Application RFC passes then the closure wont be necessary

https://wiki.php.net/rfc/partial_function_application_v2




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: