PHP implode string with single quote

Hi Guys,

If you want to implode string with single quote, then use the following code snippet:

$inputString = ‘string1, string2, string3’;
$inputString = explode(‘,’,$inputString);
$outputString = “‘” . implode( “‘,'”, array_unique($inputString) ) . “‘”;

Output : // ‘string1′,’string2,’string3’

That’s it ! You are done.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s