Categorized | PHP

Word Count, Syllable Count, Sentence Count, Flesch Reading Ease Score, etc.

I forget where exactly I lifted these from, but they’ve been very useful for some coding projects I’ve been working on silently in the background.

Maths and English

Maths and English

I thought I would share them here. Enjoy and use responsibly.

Maths and english, boys, maths and english…

// Number of words: number of space series or linebreaks + 1
$wc = preg_match_all( '/[ \r]/', preg_replace( '/ +/', ' ', $mynewtext), $tmp );
// Number of syllables: vowels not followed by another vowel. Quite accurate approximation.
$syc = preg_match_all( '/[aeiouy][^aeiouy]/', $mynewtext, $tmp );
// Number of polysyllabic words (>=3 syllables): Vowel, non-spaces, vowel, non-spaces, vowel (or more non-spaces-vowel)
$psyc = preg_match_all( '/[aeiouy]([^ ]*[aeiouy]){2,}/', $mynewtext, $tmp );
// Number of sentences: Number of periods, exclamation marks, question marks and linebreaks
$sec = preg_match_all( '/[.!?\r]/', $mynewtext, $tmp );
// Flesch Reading Ease Score
$fres = 206.835 - 1.015 * ( $wc / $sec ) - 84.6 * ( $syc / $wc );
// Simple Measure of Gobbledygook
$smog = 1.043 * sqrt( $psyc * ( 30 / $sec ) ) + 3.1291;

This post was written by:

- who has written 1099 posts on Webmaster Chronic Blog.

poet, publisher

Contact the author

6 Responses to “Word Count, Syllable Count, Sentence Count, Flesch Reading Ease Score, etc.”

  1. May says:

    Don’t use these. They suck.

  2. kpaul says:

    what do you recommend?

  3. Twitter says:

    Halo Innovations Sleepsack Swaddle Micro Fleece, Cream, Newborn (Baby Product)
    By Halo Innovations

    Buy new: $19.99
    9 used and new from $14.99
    Customer Rating:

    First tagged "baby" by Andromoda Flesch
    Customer tags: halo(2), sleepsack(2), swaddle(2), swaddling, sleepwear, baby, baby swaddling, halo swaddle sleepsack sids

  4. _jaystinee says:

    17) You, The only who's reading this ;) #20PeopleILove

  5. dialectblog says:

    It means people spend more time reading the word of God than with God Himself. class=” ” class=” ” What does the last sentence mean?”

  6. _NowAvailable_ says:

    Goodnight Tweeps count your blessings and say a prayer


Leave a Reply

Webmaster Chronic

<p><a href=\"\">EastcoastHobo</a> has added a photo to the pool:</p><p><a href=\"\" title=\"personal \"><img src=\"\" width=\"240\" height=\"180\" alt=\"personal \" /></a></p><p></p>