Tag Archive | "PHP snippets"

maths-and-english

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;
Tags: , , , , , , , , , , , , , ,

Posted in PHPComments (6)

stockxpertcom_id427371_jpg_52b9c0eb0a111428fa0f9a645ff264e4

Quick and Dirty CSV to RSS/XML for WordPress Import…

After running, you can view the source and save the output to an XML file that you can import into WP. Nothing fancy, but thought it might help one or two ppl… It is set-up to date the posts every 12 hours, although this is easily changed…

Read the full story

Tags: , , , , , , , , , , , , , ,

Posted in PHP, SnippetsComments (2)


Webmaster Chronic

@FiverWeed has added a photo to the pool:con puntos blancos / mary @FiverWeed twitter /tumblr/ blogger