scan4jobs

What is difference between explode and implode in php

0
0

What is difference between explode and implode in php

  • You must to post comments
0
0

PHP implode() Function

Example

Join array elements with a string:

<?php
$arr = array(‘Hello’,’World!’,’Beautiful’,’Day!’);
echo implode(” “,$arr);
?>

Definition and Usage

The implode() function returns a string from the elements of an array.

Note: The implode() function accept its parameters in either order. However, for consistency with explode(), you should use the documented order of arguments.

Note: The separator parameter of implode() is optional. However, it is recommended to always use two parameters for backwards compatibility.

Note: This function is binary-safe.

Syntax

implode(separator,array)

 


PHP explode() Function

Example

Break a string into an array:

<?php
$str = “Hello world. It’s a beautiful day.”;
print_r (explode(” “,$str));
?>

Definition and Usage

The explode() function breaks a string into an array.

Note: The “separator” parameter cannot be an empty string.

Note: This function is binary-safe.

Syntax

explode(separator,string,limit)
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website