SEO Chrome Extension Interested in SEO Review Tools for Chrome? Learn more..

Multi keyword density checker PHP script v1

VN:F [1.9.22_1171]
Rating: 9.1/10 (38 votes cast)

Keyword density.

Keyword density is used to determine the number of times a keyword or keyword phrase occurs on a web page / section of content compared to the total number of words found. Many of us are not convinced keyword density is a very important metric for search engines. This is also my personal opinion, but on the other hand I’m convinced it can be used to find interesting insights.

So I’ve decided to make this piece of code publicly available, and in the meantime I’ll think about a useful way to use this functionality (or just a piece of it) as part of another tool.

About the PHP script

  • Extracting content from a web page – Currently the script is able to process a string of words.
  • Stop Words – You can add expand the list of stop words with relevant words for your language, just do a quick search on Google.
  • Function – This code makes use of a function. This isn’t strictly necessary, but for future purposes I think it’s convenient.
  • Generating output – The current code outputs tables using separate foreach loops. You can tinker with it and make it a little more dynamic. But for now I think it’s a good solution to make the code accessible and not over complicated.

To do list (future versions)

  • Extracting content from a page
  • Create a more advanced filter to remove non relevant (reading) characters, so they don’t mess with the output.
  • Your suggestions…!

Current version V1

This isn’t the final version! When i’ve got some spare time I’ll work on the code and add the above features. In the meantime have fun with the code and check this page for future releases and updates.

Keyword density checker PHP script

Download the Multi Keyword density checker PHP script

Function output

Sample of the keywordSorting function. In bold you can find the explanation.

keyword density array

keyword density array

Question or suggestions?

Just let me know… And I’ll see what I can do!!

Multi keyword density checker PHP script v1, 9.1 out of 10 based on 38 ratings PHP

7 thoughts on “Multi keyword density checker PHP script v1

  1. Martin M says:

    Hey can you specify under what license you publish your code? We’d like to use part of it in an open source project.

    1. Admin says:

      Hey Martin,

      No problem, you can use it for your project. And a reference to the original script is appreciated..
      Success building something nice!

      1. Martin M says:

        Thanks, here’s the project: https://github.com/MP2-IT-Solutions/keywordanalyst
        It shows the keyword density of articles in the backend of the Contao CMS.
        Feel free to use it and contribute to it if you happen to have a need for the module :)

  2. This is a very good script.. Thank you Jasja!
    My contribution: Since the “str_word_count” does not work for all languages i would change it to “explode”, and it makes everything work for all languages.

    change these lines to this:
    $keywordsArray = str_word_count_utf8($wordStringFiltered);
    $wordCount = count($keywordsArray);

    as this function at the bottom:
    function str_word_count_utf8($str)
    {
    $str = str_replace(array(‘.’, ‘,’, ‘;’), ” , $str);
    $words_to_count = trim( preg_replace(“/\s+/”, ” “, $str) );
    return explode(” “,$words_to_count);
    }

    1. Admin says:

      Hi Kossi, thanks for your input when I’ve got some time I’ll test your suggestion and I’ll add some extra features / improvements.

  3. Tolga says:

    Hello,
    Thank you for script,
    But i can’t work special chars, (é,ı,ç.ö etc)
    How i can fix it ?

    1. Admin says:

      Hey Tolga,

      At the moment I don’t have the time to work on this script, but you can have a look at: PHP Simple HTML DOM Parser (http://simplehtmldom.sourceforge.net/).

      This is a pretty well documented html parser you can use to extract the text from a web page. I only did some quick testing so far, but I do think it can handle special characters.

Leave a Reply

Your email address will not be published. Required fields are marked *

Seen on …

Numbers and stats

16,000+

Registered Members

9.3 / 10

Avg. tool rating

162,000

Monthly visitors

45%

Returning visitors

SEO Chrome Extension Install SEO Review Tools for Chrome

Tool Alert (!)

SEO Review Tools for Chrome is a free extension which allows you to quickly check the URL your visiting, with one of these (18) SEO tools:

SEO Review Tools for Chrome
Close