Search code examples
phparraysimplode

How to create with comma separated with single qoutes list from array in PHP?


This is my question that i have this type of string

04/19/2017, 04/20/2017, 04/26/2017, 04/28/2017

i want to output as like below output

'04/19/2017','04/20/2017','04/26/2017','04/28/2017'

Solution

  • Without using explode and implode

    $string = "04/19/2017, 04/20/2017, 04/26/2017, 04/28/2017"; $string = "'".str_replace(", ","','",$string)."'";