- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to convert array to string PHP?
To convert array to string, use the concept of implode () in PHP. Let’s say the following is our array −
$sentence = array('My','Name','is','John');
To convert the above array to string −
,implode(" ",$sentence)
Example
<!DOCTYPE html> <html> <body> <?php $sentence = array('My','Name','is','John'); echo "The string is=",implode(" ",$sentence); ?> </body> </html>
Output
The string is = My Name is John
Let us now see another PHP code wherein we will add separator as well −
Example
<!DOCTYPE html> <html> <body> <?php $sentence = array('One','Two','Three'); echo "The string is=",implode("*",$sentence); ?> </body> </html>
Output
The string is = One*Two*Three
- Related Articles
- How to convert PHP array to JavaScript array?
- How to convert Multidimensional PHP array to JavaScript array?
- How to convert string to boolean in PHP?
- How to convert an array to SimpleXML in PHP?
- how to convert Object array to String array in java
- How to convert a string into number in PHP?
- How to convert XML file into array in PHP?
- How to convert string to char array in C++?
- How to convert a Python csv string to array?
- How to convert an array to string in java?
- how to convert vector to string array in java
- How to convert byte array to string in C#?
- How to convert an array into JavaScript string?
- How to convert a Double array to a String array in java?
- Convert object to an array in PHP.

Advertisements