| Newsgroups |
php.notes |
| Message-ID |
<[email protected]> |
This can be a replacement for array_filter() where an existence check is the only purpose. But, unlike array_filter(), the callback always requires two arguments. There's no way to change this, so some a lot of old-fashioned string callables are no longer usable.
<?php
$arr = [45, 'abc', 'def', 'ghi'];
if (array_filter($arr, 'is_integer')) {
// works because of loose comparison: [45] == true
}
if (array_any($arr, 'is_integer')) {
// PHP Warning: Uncaught ArgumentCountError: is_integer() expects exactly 1 argument, 2 given
}
?>
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.84.18 (proxied: 68.146.240.197)
----
Manual Page -- https://php.net/manual/en/function.array-any.php
Edit -- https://main.php.net/note/edit/130481
Del: integrated -- https://main.php.net/note/delete/130481/integrated
Del: useless -- https://main.php.net/note/delete/130481/useless
Del: bad code -- https://main.php.net/note/delete/130481/bad+code
Del: spam -- https://main.php.net/note/delete/130481/spam
Del: non-english -- https://main.php.net/note/delete/130481/non-english
Del: in docs -- https://main.php.net/note/delete/130481/in+docs
Del: other reasons-- https://main.php.net/note/delete/130481
Reject -- https://main.php.net/note/reject/130481
Search -- https://main.php.net/manage/user-notes.php