php method to convert an array into a string: first create a PHP sample file; then define an array data as "$arr"; then use the "implode($arr);" method to convert the array into String; finally output the conversion result.
Recommended: "PHP Video Tutorial"
The operating environment of this tutorial: Windows 7 system, PHP version 5.6, This method works for all brands of computers.
PHP implode(): Array to string
implode() function can convert a one-dimensional array into a string. The syntax format is as follows:
implode($glue, $array) or implode($array)
Among them, $glue is used to set a string, indicating that $glue is used to connect each element of the array together. By default $glue is an empty string; $array is the array that needs to be converted.
Tip: The $glue parameter of the implode() function is optional and can be omitted.
[Example] Use the implode() function to convert an array into a string.
<?php $arr = ['PHP中文网','PHP教程','http://www.php.cn/php/','implode()函数','数组转字符串']; $str = implode($arr); echo $str.'<br>'; $str = implode(' ',$arr); echo $str.'<br>'; $str = implode(',',$arr); echo $str.'<br>'; $str = implode('--',$arr); echo $str.'<br>'; ?>
The running results are as follows:
PHP中文网PHP教程http://www.php.cn/php/implode()函数数组转字符串 PHP中文网 PHP教程 http://www.php.cn/php/ implode()函数 数组转字符串 PHP中文网,PHP教程,http://www.php.cn/php/,implode()函数,数组转字符串 PHP中文网--PHP教程--http://www.php.cn/php/--implode()函数--数组转字符串
The above is the detailed content of How to convert array into string in php. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver CS6
Visual web development tools
