PHP explode() string conversion array_PHP tutorial

WBOY
Release: 2016-07-20 11:03:30
Original
1199 people have browsed it

There are many ways to convert strings into arrays in PHP. If we have regularity, we can directly use the explode() function to cut the string into an array. ​

Definition and usage

The explode() function splits a string into an array.

Grammar

explode(separator,string,limit)

Example

In this example, we will split the string into an array:

The code is as follows Copy code
 代码如下 复制代码

$str = "Hello world. It's a beautiful day.";
print_r (explode(" ",$str));
?>

$str = "Hello world. It's a beautiful day.";
print_r (explode(" ",$str));
?>

Output:
 代码如下 复制代码

Array
(
[0] => Hello
[1] => world.
[2] => It's
[3] => a
[4] => beautiful
[5] => day.
)

The code is as follows Copy code

Array
(
[0] => Hello
[1] => world.
[2] => It's
[3] => a
[4] => beautiful
[5] => day.
)


In this way, our characters will be converted into arrays according to our settings.

http://www.bkjia.com/PHPjc/445285.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445285.htmlTechArticle
There are many ways to convert strings into arrays in php. If we have regularity, we can use it directly. explode() function to cut the string into an array. Definition and usage explode() function puts...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!