PHP code example of tinusg / syllable-counter
1. Go to this page and download the library: Download tinusg/syllable-counter 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/ */
tinusg / syllable-counter example snippets
$counter->count('Sophia'); // 3
$counter->hyphenate('Sophia'); // "So-phi-a"
$counter->split('Sophia'); // ['So', 'phi', 'a']
use TinusG\SyllableCounter\SyllableCounter;
class NameController
{
public function show(SyllableCounter $syllables, string $name)
{
return view('names.show', [
'syllableCount' => $syllables->count($name),
'hyphenated' => $syllables->hyphenate($name),
]);
}
}
$counter->count('Anne-Marie'); // 4
$counter->split('Anne-Marie'); // ['An', 'ne', 'Ma', 'rie']
$counter->count('Céline', muteFinalE: true); // 2 → Cé-line
$counter->count('Eline', muteFinalE: false); // 3 → E-li-ne
$counter->count('Hatice', muteFinalE: false); // 3 → Ha-ti-ce, overriding the -ce rule
return [
'exceptions' => [
'ilse' => ['il', 'se'],
],
];
new SyllableCounter(['ilse' => ['il', 'se']]);
bash
php artisan vendor:publish --tag=syllable-counter-config