Home > Article > Backend Development > How to convert array to string type in php
In PHP, you can use the implode() function to convert an array into a string type. The syntax format is "implode(array)"; this function can convert a one-dimensional array into a string and then return a A string composed of array array elements.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php converts the array into string
<?php $arr = array('Hello','World!','Beautiful','Day!'); $str = implode(" ",$arr); var_dump($str); ?>
Output:
string 'Hello World! Beautiful Day!' (length=27)
Related function introduction:
implode() function can convert a one-dimensional array into characters String, its syntax format is as follows:
implode(separator,array)
Return value: Returns a string composed of array elements.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to convert array to string type in php. For more information, please follow other related articles on the PHP Chinese website!