Home  >  Article  >  Backend Development  >  PHP string to array and array to string

PHP string to array and array to string

不言
不言Original
2018-04-09 17:48:381910browse

The content of this article is to share with you PHP string to array and array to string. Friends in need can refer to it


//数组按指定方式分割为字符串
$arr = array('Hello','World!','I','love','Shanghai!');
    
echo implode(" ",$arr);

//字符串按指定规则合并为数组
$string = "Hello World love Shanghai";

$arr = explode(" ", $pizza);

print_r($arr);

Related recommendations:

php character encoding conversion

Detailed explanation of the difference between three PHP string delimiters

php string usage Detailed explanation


The above is the detailed content of PHP string to array and array to string. For more information, please follow other related articles on the PHP Chinese website!

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