Contact me See Resume

Array to string conversion using implode function - nareshonline.com

Array to string conversion using implode function

Catagory : PHP and mySQLi Posted : July, 01, 2018

In this tutorial we will discuss about PHP default function called implode. We can easily make an array to string conversion using implode function.

implode()

Returns string from an array elements (values);

The implode() function is very useful in SELECT query in mysqli.

Arguments

The implode function takes two arguments. First is separator in sting form and second is elements (values) of array.

The default separator is blank (empty string).

For details Please refer http://php.net/manual/en/function.implode.php.

Exp:

Lest create an array with two elements and take output.

$str = ["PHP is a programming language.", "PHP is used for Web programming."];

echo $str = implode(" ", $str)."<br>";

Here I am using ” ” blank space to join to string. So result will in continuous paragraph.

Result :

PHP is a programming language. PHP is used for Web programming.

Leave a Reply

You have to agree to the comment policy.