PHP Discarding Empty Elements With Preg_Split() – String Function

<?
$text=<<<text
"asdf.asdf,asdf!asdf
TEXT;$words = preg_split('/[",.!\s]/', $text, -1, PREG_SPLIT_NO_EMPTY);print 'There are ' . count($words) .' words in the text.';
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.