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

How to change php array to characters

藏色散人
Release: 2023-03-11 07:26:01
Original
1388 people have browsed it

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) ""
 
?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template