Home > Backend Development > PHP Tutorial > PHP method to return all words in a string, PHP returns string words_PHP tutorial

PHP method to return all words in a string, PHP returns string words_PHP tutorial

WBOY
Release: 2016-07-13 10:04:28
Original
846 people have browsed it

php method to return all words in a string, php to return string words

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:

<&#63;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];
}
&#63;>
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/965354.htmlTechArticlephp method to return all words in a string, php returns string words All word methods. Share it with everyone for your reference. Specific analysis is as follows...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template