The example in this article describes the method of php to return all words in a string. Share it with everyone for your reference. The specific analysis is as follows:
This code returns all words in the string, removing duplicate elements when $distinct=true. The code is as follows:
<?php function split_en_str($str,$distinct=true) { preg_match_all('/([a-zA-Z]+)/',$str,$match); if ($distinct == true) { $match[1] = array_unique($match[1]); } sort($match[1]); return $match[1]; } ?>
I hope this article will be helpful to everyone’s PHP programming design.