- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is implode() function in PHP?
In this article, learn how to use PHP Implode() function.The Implode() function is a predefined inbuilt PHP function. We can form a string by joining the components of an array with the help of the PHP implode function. The implode() function creates a string from components of an array utilizing a delimiter of our choice. The implode() function acknowledges two parameters out of which one is optional and one is mandatory.
Let's learn those parameters.
This is an optional parameter and is of string type. The values of the array will be join to form a string and will be separated by the separator parameter provided here.
The array whose value is to be joined to form a string.
<?php $arr = array ('Welcome','To','Tutorials','Point'); $comma_separated = implode(" , ", $arr); $hyphen_separated = implode(" - ", $arr); echo $comma_separated"
" ; echo implode(" ",$arr)"
"; echo $hyphen_separated; ?>
Welcome , To , Tutorials , Point Welcome To Tutorials Point Welcome - To - Tutorials - Point
In the first expression, we have used a comma "," as a separator to form string. In the second expression, we have used space " " as a separator to demonstrate the implode function.
- implode() function in PHP
- What is header() function in PHP?
- What is explode() function in PHP?
- What is traits in PHP?
- What is .htaccess in PHP?
- What is method overloading in PHP?
- What is dependency injection in PHP?
- What is Exception Handling in PHP ?
- What is Trailing Comma in PHP?
- What is PHP Output Buffering?
- file_exists() function in PHP
- basename( ) function in PHP
- chgrp()function in PHP
- chmod() function in PHP
- chown() function in PHP