PHP code example of alfreddagenais / php-word-count-utf8

1. Go to this page and download the library: Download alfreddagenais/php-word-count-utf8 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alfreddagenais / php-word-count-utf8 example snippets



use AlfredDagenais\WordCountUtf8;

// Example 1
$text = "This string has five words!";
$count = WordCountUtf8::getWordCount($text); // int(5)
$count = WordCountUtf8::getCharacterCount($text); // int(27)
$count = WordCountUtf8::getCharacterWithoutSpaceCount($text); // int(23)

// Example 2
$text = "When you don't create things, you become defined by your tastes rather than ability. your tastes only narrow and exclude people. so create.";
$count = WordCountUtf8::getWordCount($text); // int(23)
$count = WordCountUtf8::getCharacterCount($text); // int(139)
$count = WordCountUtf8::getCharacterWithoutSpaceCount($text); // int(117)

// Example 3
$text = "Un langage qui n'affecte pas votre manière de penser la programmation ne vaut pas la peine d'être connu.";
$count = WordCountUtf8::getWordCount($text); // int(18)
$count = WordCountUtf8::getCharacterCount($text); // int(104)
$count = WordCountUtf8::getCharacterWithoutSpaceCount($text); // int(87)