Implode and Explode in PHP

[ad_1]

Implode and explode function in PHP; Through this tutorial, we will show you everything about implode() and explode() function in PHP.

We can use both functions with PHP arrays and strings. And here also take examples like an array to string conversion in PHP, the string to array conversion in PHP.

Implode and Explode in PHP

  • PHP implode() Function
  • PHP Explode Function

PHP implode() Function

Implode function is a built-in function of php, which is used to convert array to string by provided delimiter.

Syntax

implode(separator,array)

Parameters of implode function

Parameter Description
separator It’s optional parameters. By default set empty.
array Required. The array to join to a string

Example:- array to string conversion in php

<?php 
$array = array('1','2','3','4','5');
echo implode(" ", $array);

Output

1,2,3,4,5

PHP Explode Function

Explode function is a built-in function of php, which is used to convert/break string to an array by a provided delimiter.

Syntax

explode(separator,string,limit)

Parameters of explode function

Parameter Description
separator It’s is delimeter and required.
string String, which you want to break
limit Optional. Specifies the number of array elements to return.

Example:- string to array conversion in php

<?php
$string = "1,2,3,4,5";
print_r(explode(",", $string));

Output

Array ([0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5)

Recommended PHP Tutorials

  1. Compare Arrays PHP | PHP array_diff() Function
  2. Get, Write, Read, Load, JSON File from Url PHP
  3. Functions: Remove First Character From String PHP
  4. Remove Specific/Special Characters From String In PHP
  5. How to Replace First and Last Character From String PHP
  6. Reverse String in PHP
  7. Array Push, POP PHP | PHP Array Tutorial
  8. PHP Search Multidimensional Array By key, value and return key
  9. json_encode()- Convert Array To JSON | Object To JSON PHP
  10. PHP remove duplicates from multidimensional array
  11. PHP Remove Duplicate Elements or Values from Array PHP
  12. Get Highest Value in Multidimensional Array PHP
  13. PHP Get Min or Minimum Value in Array
  14. String PHP to Uppercase, Lowercase & First Letter Uppercase
  15. PHP: isset() vs empty() vs is_null()
  16. Chunk_split PHP Function Example
  17. PHP Function: Date and Time With Examples
  18. Reverse Number in PHP | PHP Tutorial

[ad_2]

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

GSTIN is 03EGRPS4248R1ZD.

Contact
Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00