require_once __DIR__.'/includes/hashtag_library.php'; /** * Generate 15–20 Instagram hashtags using the 'Staircase Method' */ function generate_instagram_hashtags(string $title): array { global $HASHTAG_LIBRARY; $titleLower = mb_strtolower($title, 'UTF-8'); // 1. Determine Niche $niche = 'general'; $nicheMap = [ 'funny' => '/(funny|comedy|meme|lol|humor|joke|laugh)/i', 'gaming' => '/(gaming|game|pubg|valorant|bgmi|freefire|xbox|playstation|clutch)/i', 'love' => '/(love|romantic|couple|relationship|heart|sad|shayari)/i', 'motivation' => '/(motivation|inspire|success|hustle|grind|goal|business)/i', 'tech' => '/(tech|technology|ai|coding|web|software|phone|gadget)/i' ]; foreach($nicheMap as $key => $pattern) { if (preg_match($pattern, $titleLower)) { $niche = $key; break; } } // 2. Select Tags (Staircase Method) $nicheTags = $HASHTAG_LIBRARY[$niche]; $generalTags = $HASHTAG_LIBRARY['general']; $easy = []; $medium = []; $hard = []; // Helper to categorize $categorize = function($tagArray) use (&$easy, &$medium, &$hard) { foreach($tagArray as $t) { if ($t['diff'] === 'Easy') $easy[] = $t; elseif ($t['diff'] === 'Medium') $medium[] = $t; else $hard[] = $t; } }; $categorize($nicheTags); if ($niche !== 'general') { $categorize($generalTags); } // Unique check $easy = array_values(array_unique($easy, SORT_REGULAR)); $medium = array_values(array_unique($medium, SORT_REGULAR)); $hard = array_values(array_unique($hard, SORT_REGULAR)); shuffle($easy); shuffle($medium); shuffle($hard); // Build balanced set (Aim for ~20) // 7 Easy, 7 Medium, 6 Hard $results = array_merge( array_slice($easy, 0, 8), array_slice($medium, 0, 7), array_slice($hard, 0, 5) ); // If still short, fill with anything if (count($results) < 15) { $remaining = array_merge($easy, $medium, $hard); foreach($remaining as $r) { $found = false; foreach($results as $res) { if($res['tag'] === $r['tag']) { $found=true; break; } } if(!$found) $results[] = $r; if(count($results) >= 20) break; } } return $results; } $title = ''; $hashtags = []; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $title = trim($_POST['title'] ?? ''); if ($title !== '') { $hashtags = generate_instagram_hashtags($title); } } ?>

AI Hashtag Generator

Paste your Instagram post or reel title and let our AI scrape trends, analyze engagement & rank the best 15–20 hashtags for you.
Trend-based AI Engine
Idle – waiting for your title…
✨ Tip: Use detailed titles like “Romantic couple reel with Hindi song and slow motion” or “BGMI clutch gameplay montage 1v4” for more accurate hashtag suggestions.

Someone just bought 1000 Followers

Just now ● Verified