sylae/word-count

PHP port of the Javascript iarna/word-count

Maintainers

Package info

github.com/sylae/word-count

pkg:composer/sylae/word-count

Fund package maintenance!

Patreon

paypal.me/MisfitMaid

Statistics

Installs: 971

Dependents: 0

Suggesters: 0

Stars: 3

Open Issues: 2

v1.1 2021-05-31 13:25 UTC

This package is auto-updated.

Last update: 2026-03-17 02:14:08 UTC


README

PHP port of iarna/word-count. This should provide an accurate wordcount taking into account apostrophes and hyphens and stuff. See iarna's project for disclaimers on what languages this method may not work well with.

Usage

composer require sylae/word-count

<?php

use Sylae\Wordcount;

$string = "This string has five words!";

$count = Wordcount::count($string); // int(5)

Contributing

I mean if you want to cool i guess <3

  1. PSR-2.
  2. Write tests.
  3. Yeet me a PR.

I'm lowkey pretty sure ::count() could be improved with fancy regex magic, but I'm a dumb bitch so idk.

Versioning

semver.

License

MIT.