3v4l.org

run code in 300+ PHP versions simultaneously
<?php function cleanWord( &$word ){ $word = trim($word, "'\".!<>{}()-/\*&^%$#@+~ "); } // list of comments $arr_str = [ " this!! is the first &test message./", "*Second ^message this (is) ", "'another\ **message*** !\"}& it is. also the favorite one (message)." ]; // To join array's items $str = implode(" ", $arr_str); // To chop the string based on the space $words = explode(" ",$str); // To remove redundant character(s) array_walk($words, 'cleanWord'); // To remove empty array elements $words = array_filter($words); print_r($words);

preferences:
28.64 ms | 409 KiB | 5 Q