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

How to convert array into string in php

藏色散人
藏色散人Original
2020-11-06 10:45:092286browse

php method to convert an array into a string: first create a PHP sample file; then define an array; then convert the array into a string through the "implode(',',$arr);" method; Finally, the conversion result can be output through echo.

How to convert array into string in php

Recommended: "PHP Video Tutorial"

The code example is as follows:

$arr = array(1,2,3,4,5,6,7);
echo implode(',',$arr);
//结果:"1,2,3,4,5,6,7"
echo implode('-',$arr);
//结果:"1-2-3-4-5-6-7"

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!

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