sylae/word-count

PHP port of the Javascript iarna/word-count

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

This package is auto-updated.

Last update: 2024-05-16 21:48:49 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.