How to convert an array to a string in php
In this article Xiaobian for you to introduce in detail "how to convert an array into a string in php", the content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to convert an array into a string in php" can help you solve your doubts.
Conversion method: 1, using the foreach statement and the ". =" symbol, syntax "foreach ($arr as $key = > $value) {$str. =','. $value;}"; 2, using the implode () function, syntax "implode (',', $arr)".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Convert an array to a string in php
Method 1: use the foreach statement and the ". =" character splicer
First use the foreach statement to traverse the array
Use ". =" to splice array elements together to form a string.
2. Use the implode function
The implode () function returns a string composed of array elements.
Grammar
Implode (separator,array)
Separator is optional. Specifies what to place between the elements of the array. The default is "" (empty string).
Array is required. An array to be combined into a string
After reading this, the article "how to convert an array into a string in php" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it to understand it. If you want to know more about the article, please follow the industry information channel.