Learn when you want, where you want with convenient online training courses. Sign up now!
[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
<?php // demo/temp_ramu.php
// A TEXT TO BUILD A CONCORDANCE
$text = <<<EOD
This is the list of words that should be excluded from the lookup. Mostly these
are common words without "term of art" meanings. You might want to add to this
list to suppress false-positive matches in your industry. If you're a church
you might want to exclude "bible" or "worship"; if you're a car dealership you
might want to exclude "car" from the search, etc.
// A COLLECTION OF WORDS TO SEARCH FOR IN THE TEXT
$find = <<<EOD
// BUILD THE CONCORDANCE
$text = preg_replace('/[^A-Z]/i', ' ', $text); // ALPHABET ONLY
$text = preg_replace('/\s\s+/', ' ', $text); // NORMALIZE WHITESPACE
$text = explode(' ', $text);
$list = ;
foreach ($text as $word)
$word = strtolower($word);
if (!array_key_exists($word, $list)) $list[$word] = 0;
// FIND THE OCCURRENCES OF THE SEARCH WORDS
$find = preg_replace('/[^A-Z]/i', ' ', $find); // ALPHABET ONLY
$find = preg_replace('/\s\s+/', ' ', $find); // NORMALIZE WHITESPACE
$find = explode(' ', $find);
foreach ($find as $word)
if (array_key_exists($word, $list))
echo PHP_EOL . "$word: " . $list[$word];
echo PHP_EOL . "$word not found";
Open in new window
gooseball not found
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.