Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. $info = explode("\n", $nfo);
  2. $tags = array('games'   => array('text'     => 'Games',
  3.                                  'genres'   => array('keywords' => array('genre', 'game type'),
  4.                                                      'options'  => array('action', 'adventure', 'dance'),
  5.                                                      ),
  6.                                  ),
  7.               'books'   => array('text'     => 'Books',
  8.                                  'genres'   => array('keywords' => array('genre', 'book type'),
  9.                                                      'options'  => array('suspense', 'romance', 'fiction'),
  10.                                                      ),
  11.                                  ),
  12.               'music'   => array('text'     => 'Music',
  13.                                  'genres'   => array('keywords' => array('genre', 'music type'),
  14.                                                      'options'  => array('rap', 'country', 'blues', 'jazz'),
  15.                                                      ),
  16.                                  ),                              
  17.               );
  18.  
  19. unset($tags);
  20. foreach ($info as $index => $infoLine)
  21. {
  22.     foreach ($tags as $genre => $genreData)
  23.     {
  24.         $tags .= (($tags) ? ',' : '') . $genreData['text'];
  25.        
  26.         foreach ($genreData['genres'] as $index => $genreOptions)
  27.         {
  28.             $keywords = $genreOptions['keywords'];
  29.             $options = $genreOptions['options'];
  30.            
  31.             foreach ($keywords as $index => $keyword)
  32.             {
  33.                 if (strpos($infoLine, $keyword) === true)
  34.                 {
  35.                     foreach ($options as $index => $option)
  36.                     {
  37.                         if (strpos($infoLine, $option) === true)
  38.                         {
  39.                             $tags .= (($tags) ? ',' : '') . ucwords($option);
  40.                         }
  41.                     }
  42.                 }
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement