Home >Backend Development >PHP Problem >How to change php array to characters

How to change php array to characters

藏色散人
藏色散人Original
2021-07-02 09:50:261386browse

How to change a php array into a character: first create a PHP sample file; then define an array; and finally use the implode function to turn the array into a string.

How to change php array to characters

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

How to change the php array into characters?

PHP Array to String

implode Use a string to convert an array into a string

<?php
 
$array = array(&#39;lastname&#39;, &#39;email&#39;, &#39;phone&#39;);
$comma_separated = implode(",", $array);
 
echo $comma_separated; // lastname,email,phone
 
// Empty string when using an empty array:
var_dump(implode(&#39;hello&#39;, array())); // string(0) ""
 
?>

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to change php array to characters. 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