public static function hasTag($bean, $tags, $all = false) { $foundtags = RedBean_Facade::tag($bean); if (is_string($foundtags)) { $foundtags = explode(",", $tags); } $same = array_intersect($tags, $foundtags); if ($all) { return implode(",", $same) === implode(",", $tags); } return (bool) (count($same) > 0); }