mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Fix strict count() behavior in PHP 7.2
This commit is contained in:
parent
6f7f92f3e2
commit
6f35f5bafc
7 changed files with 43 additions and 16 deletions
|
|
@ -517,6 +517,28 @@ function tobool($input)
|
|||
return (bool)$input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts members of an array or an object.
|
||||
*
|
||||
* @param mixed $array_or_object
|
||||
* @return int
|
||||
*/
|
||||
function countobj($array_or_object)
|
||||
{
|
||||
if (is_array($array_or_object))
|
||||
{
|
||||
return count($array_or_object);
|
||||
}
|
||||
elseif (is_object($array_or_object))
|
||||
{
|
||||
return count(get_object_vars($array_or_object));
|
||||
}
|
||||
else
|
||||
{
|
||||
return @count($array_or_object);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given string contains valid UTF-8.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue