PHP Using Preg_Grep() – String Function

<?
$text=<<<text
"asdf.asdf,asdf!asdf
TEXT;$words = preg_split('/[",.!\s]/', $text, -1, PREG_SPLIT_NO_EMPTY);$double_letter_words = preg_grep('/([a-z])\\1/i',$words);foreach ($double_letter_words as $word) {
    print "$word\n";
}
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.