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