How to convert php array string to array

藏色散人
Release: 2023-03-07 22:50:01
Original
2847 people have browsed it

How to convert php array string to array: 1. Use the "implode(" ",$arr);" method to split the array into strings in the specified way; 2. Use "explode(" ", $ pizza);" method merges strings into arrays according to specified rules.

How to convert php array string to array

#Environment of this article: Windows7 system, PHP7.1, Dell G3 computer.

Recommended: "PHP Video Tutorial"

PHP String to Array and Array to String

//数组按指定方式分割为字符串
$arr = array('Hello','World!','I','love','Shanghai!');
    
echo implode(" ",$arr);
 
//字符串按指定规则合并为数组
$string = "Hello World love Shanghai";
 
$arr = explode(" ", $pizza);
 
print_r($arr);
Copy after login

implode( ) function returns a string composed of array elements.

explode() function uses one string to split another string and returns an array composed of strings.

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

Related labels:
php
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