
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert Array to String in 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
Advertisements