note 129929 added to function.count
| From: | mars@tacks.com | Date: | Sat, 21 Dec 2024 16:12:18 +0000 |
| Subject: | note 129929 added to function.count | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221736@lists.php.net to get a copy of this message | ||
Perhaps this could help someone :
<?php
function array_contains_recursion(array $array): bool {
$result = false;
set_error_handler(function (int $a, string $b, string $c, int $d) use (&$result) : bool {
$result = true;
return true;
});
$_ = count($array, COUNT_RECURSIVE);
restore_error_handler();
return $result;
}
// ...
$a = [];
var_dump(array_contains_recursion($a)); // false
$a[] = &$a;
var_dump(array_contains_recursion($a)); // true
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 2a01:e0a:95c:f140:d934:6ca3:9751:10a4)
----
Manual Page -- https://php.net/manual/en/function.count.php
Edit -- https://main.php.net/note/edit/129929
Del: integrated -- https://main.php.net/note/delete/129929/integrated
Del: useless -- https://main.php.net/note/delete/129929/useless
Del: bad code -- https://main.php.net/note/delete/129929/bad+code
Del: spam -- https://main.php.net/note/delete/129929/spam
Del: non-english -- https://main.php.net/note/delete/129929/non-english
Del: in docs -- https://main.php.net/note/delete/129929/in+docs
Del: other reasons-- https://main.php.net/note/delete/129929
Reject -- https://main.php.net/note/reject/129929
Search -- https://main.php.net/manage/user-notes.php