TagDecoder.inc 411 B

123456789101112131415161718
  1. <?php
  2. class TagDecoder {
  3. public function getTagIds($tagString) {
  4. $tagsFound = array();
  5. $possibleTags = explode(",", $tagString);
  6. $topicModel = new TopicModel();
  7. $allTopics = $topicModel->getAllTopicNames();
  8. foreach ($possibleTags as $oneTag) {
  9. $cleanTag = strtolower(trim($oneTag));
  10. if ($key = array_search($cleanTag, $allTopics)) {
  11. $tagsFound[] = $key;
  12. }
  13. }
  14. return $tagsFound;
  15. }
  16. }