Asked 1 years ago
19 May 2023
Views 539
eclipse-learner

eclipse-learner posted

php convert array to string ?

php convert array to string ?
jaman

jaman
answered Jun 25 '23 00:00

To convert an array to a string in PHP, you can use the implode() function . The implode() function joins the elements of an array into a single string, using a specified delimiter.

Here's an example of how to use implode() to convert an array to a string:

$array = array('apple', 'banana', 'orange');
$string = implode(', ', $array);
echo $string;

Output:


apple, banana, orange
In the example above, the $array variable contains three elements. The implode() function is then used to join these elements into a single string, with each element separated by a comma and a space. The resulting string is stored in the $string variable and then printed using echo.

Post Answer