Word Counter Online

Word Counter Online PHP

Best Word Counter Full PHP Script Code latest modified code complete coding in single file easy to use and customize.

You can modify the code with your desire for functionality and design layout.


    <section class="main-section-wrapper">
        <div class="boxes-wrapper">
            <div class="box">
                <div class="box-header" id='word'>
                    0
                </div>
                <div class="box-footer">
                    words
                </div>
            </div>
            <div class="box">
                <div class="box-header" id='letter'>
                    0
                </div>
                <div class="box-footer">
                    letters
                </div>
            </div>
            <div class="box">
                <div class="box-header" id="microphone">
                    <i class="fas fa-microphone"></i>
                </div>
                <div class="box-footer">
                    voice
                </div>
            </div>
        </div>
        <div class="form-wrapper">
        
 const paragraph = document.getElementById("paragraph");
const wordDiv = document.getElementById("word");
const btn = document.querySelector("button");
const microphone = document.querySelector("#microphone");
const letter = document.querySelector("#letter");

paragraph.addEventListener("input", function (e) {
  paragraph.textContent = e.target.value;

  letter.innerText = countCharacters(paragraph);

  const words = paragraph.textContent.trim().split(" ");
  if (paragraph.textContent === "") {
    wordDiv.textContent = 0;
  } else {
    wordDiv.textContent = words.length;
  }
});

microphone.addEventListener("click", function () {
  const speech = new SpeechSynthesisUtterance();
  speech.lang = "en-US";

  speech.text = paragraph.textContent;
  speech.volume = 1;
  speech.rate = 1;
  speech.pitch = 1;

  window.speechSynthesis.speak(speech);
});

function countCharacters(para) {
  let charLength = 0;

  const chars = [
    " ",
    "!",
    "@",
    "#",
    "$",
    "%",
    "^",
    "*",
    "(",
    ")",
    "-",
    "=",
    "?",
    ".",
    "/",
    "'",
    '"',
    "[",
    "]",
    "\\",
    ",",
  ];

  for (const element of para.value) {
    charLength++;

    for (let i = 0; i < chars.length; i++) {
      if (element === chars[i]) {
        charLength--;
      }
    }
  }

  return charLength;
  // return 0;
}

Get Word Counter Online Code

This is the justification for why we have referenced the word numbering of the website word counter PHP script.

There may be many possibilities for counting numbers and many ways.

Know the limit as minimum and maximum without wasting your time.

Simple scripting does not take much load and fast results of counting a full page.

Purpose of word counter

words counter content and make your assertion counter site
make your statement of words to know a total number of word saving time.

And letter counter site where you can glue your article and count words and letters rapidly and effectively, rank your site on top. and acquire by site or other elective sites without any problem.

Scroll to Top