Home > Article > Backend Development > PHP method to return all words in a string_PHP tutorial
This article mainly introduces the method of php to return all words in a string. An example is an analysis of php string regular matching and array The operation skills have certain reference value. Friends in need can refer to it
The example in this article describes how php returns 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:
?
3 4 5
|
function split_en_str($str,$distinct=true) {
preg_match_all('/([a-zA-Z]+)/',$str,$match); |