is_countable?!

This commit is contained in:
Min-Soo Kim 2020-06-07 22:56:21 +09:00
parent 43fe12af13
commit a641b3103a
10 changed files with 39 additions and 14 deletions

View file

@ -691,4 +691,20 @@ function is_empty_html_content($str)
$str = strip_tags($str, '<img><audio><video><iframe><object><embed>');
$str = utf8_trim(utf8_clean(html_entity_decode($str, ENT_QUOTES, 'UTF-8')));
return $str === '';
}
/**
* https://wiki.php.net/rfc/is-countable
* Check if there is 'is_countable' function (PHP 7.3)
* If there is no 'is_countable' function, define it for check Countable objects
*
* @param string $str The input string
* @return bool
**/
if (!function_exists('is_countable'))
{
function is_countable($var)
{
return is_array($var) || $var instanceof Countable;
}
}