Home  >  Article  >  Backend Development  >  Two ways to split strings word by word in PHP_PHP tutorial

Two ways to split strings word by word in PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:26:461284browse

Method one:

Note: 1. The $charset variable is the web page encoding, such as "gb2312" or "utf-8";

2. The first method requires that the server must enable the mbstring.dll extension, otherwise the code will execute incorrectly, so for those who use virtual hosts, you can consider using the second method. ​

Method 2: 127?$str[$i].$str[++$i]:$str[$i]; } return $arr; } $arr=str_to_arr($str); ? >

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/822516.htmlTechArticleMethod 1: ?php $str=Web page: http://www.wangyeba.com; functionmbstringtoarray($ str,$charset){ $strlen=mb_strlen($str); while($strlen){ $array[]=mb_substr($str,0,1,$charset);...
Statement:
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