<?php

$stopwords = ['buku', 'tentang', 'yang', 'di', 'ke', 'dari', 'mencari', 'untuk', 'dan', 'ini', 'itu', 'adalah', 'pada', 'dengan', 'sebuah', 'cara'];

function processSearch($originalSearch, $stopwords) {
    echo "Original: '$originalSearch'\n";
    $cleanInput = preg_replace('/[^\p{L}\p{N}\s]/u', '', strtolower($originalSearch));
    $words = explode(' ', $cleanInput);
    
    $filteredWords = array_filter($words, function($word) use ($stopwords) {
        return !in_array($word, $stopwords) && trim($word) !== '';
    });
    
    $processedSearch = implode(' ', $filteredWords);
    echo "Processed: '$processedSearch'\n";
    return $processedSearch;
}

processSearch('buku investasi', $stopwords);
processSearch('buku tentang investasi', $stopwords);
processSearch('investasi', $stopwords);
