Home >Backend Development >PHP Problem >How to change php array to characters
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.
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('lastname', 'email', 'phone'); $comma_separated = implode(",", $array); echo $comma_separated; // lastname,email,phone // Empty string when using an empty array: var_dump(implode('hello', 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!