Home  >  Article  >  Backend Development  >  How to convert array to string type in php

How to convert array to string type in php

青灯夜游
青灯夜游Original
2021-03-25 18:29:324027browse

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.

How to convert array to string type in php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

php converts the array into string

<?php
$arr = array(&#39;Hello&#39;,&#39;World!&#39;,&#39;Beautiful&#39;,&#39;Day!&#39;);
$str = implode(" ",$arr);
var_dump($str);
?>

Output:

string &#39;Hello World! Beautiful Day!&#39; (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)

How to convert array to string type in php

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!

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