public static function fetch_tags_from_post(post_model $post) { $post_id = $post->id; $post_tags = post_tag_model::get(array('post_id' => $post_id)); if ($post_tags === []) { return ''; } $tag_ids = []; foreach ($post_tags as $post_tag) { $tag_ids[] = (int) $post_tag->tag_id; } $tags = tag_model::get_by_ids($tag_ids); $tag_names = []; foreach ($tags as $tag) { $tag_names[] = $tag->name; } return implode(',', $tag_names); }