How PHP returns all the words in a string
This article mainly introduces the method that PHP returns all the words in the string, the example analyzes the PHP string regular match and the array operation skill, has the certain reference value, needs the friend to refer to the next
This example describes how PHP returns all the words in a string. Share to everyone for your reference. The specific analysis is as follows:
This code returns all the words in the string and removes the duplicate elements when $distinct=true. The code is as follows:
?
1 2 3 4 5 6 7 8 9 10 |
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 is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/965528.html www.bkjia.com true http://www.bkjia.com/PHPjc/965528.html techarticle how PHP returns all the words in a string this article mainly introduces the method of PHP to return all the words in the string, examples of PHP string matching and array manipulation techniques, with ...