개념은 키워드 배열과 기사가 있다는 것입니다. 나는 그 키워드 중 어떤 것이 기사의 집합에 존재 하는지를 알아 내고, 성능과 속도를 염두에 두는 것이 가장 좋은 방법인지 궁금합니다.PHP - 기사에 키워드 집합 찾기
기본적으로 키워드는 3 단어 이상으로 구성되지만 10 단어를 초과하지는 않습니다. 키워드가 기사에 존재하면 기사에있는 키워드 만 반환합니다.
$articles = "Maybe it’s less true than it used to be that people are made of
place--that the same elements that form coal and clay and bogs and ice form
faces, voices and characters. I wrote my first collection of short stories,
The Bostons, in homage to this book, hoping, as did Joyce’s young Stephen
Dedalus, to encounter for the millionth time the reality of experience and to
forge in the smithy of my soul the uncreated conscience of some island-dwellers
I knew."
키워드 :
$keywords = "less true than, people are made, smithy of my soul, uncreated
conscience, this is a test string"
밖으로 뮤스 넣어 수 :
"less true than, people are made, smithy of my soul, uncreated conscience"
이미
$articles = mb_split(' +', $articles);
foreach ($articles as $key => $word)
$articles [$key] = trim($word);
//Search for keywords
$keywords = str_replace(' ', '', $keywords);
$keywords = mb_split('[ ,]+', mb_strtolower($keywords, 'utf-8'));
$result = implode(',', array_intersect($keywords, $articles);
,536를 사용하여 프로그램
우리가 기사를 가지고 있다고 가정
하나의 키워드에 대해서만 작동합니다. 여러 키워드를 사용하는 방법을 모르겠습니다.
키워드가 실제로 여러 단어로 구성 될 수 있습니까? 예를 들어 귀하의 예에서 "키워드"가 "보다 적습니다", 맞습니까? – Nico
정규 표현식과 preg_match에 대해 들어 봤습니까? –