How to convert array to string in php

This Tutorial will focus on methods to convert array to a string. PHP provides a few methods to convert an array to strings. The arrays can be one or two-dimensional.

You can use the PHP implode, and  join functions to convert arrays to strings.

Using the implode function

<?php
$arr = array('Hello','World!','Beautiful','Day!');
echo implode(" ",$arr);
?>

Result

Hello World! Beautiful Day! 

Using the join function

<?php
$arr = array('name', 'email', 'phone');
 
$separater = join(",", $arr);
 
echo $separater;
?>

Result

name,email,phone

Leave a Reply

Related Posts: You may like

Extract Total Number of Image And Missing Alt Attribute using php

How to extract Heading tags using PHP from string

How to remove whitespace from string using php

Remove All Special Characters From String PHP

PHPKIDA Offering Free Tools:

INSTA DOWNLOADER

Download Instagram Videos & Photos.

Download Now

CURRENCY CONVERTER

Real Time Currency Converter

Convert Now

ROBOST.TXT GEN.

Robots.txt File Creater

Create Now

HTML MINIFIER

Compress yout HTML Code

Minify Now

CSS MINIFIER

Compress yout CSS Code

Minify Now

JAVASCRIPT MINIFIER

Compress yout JavaScript Code

Minify Now

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.