How to add quote to string delimited by comma in PHP
Sometimes we will have a list of string delimited by comma, e.g., a,b,c,d
, and we would like to add quote or single quote around each element, e.g., 'a','b','c','d'
. It is possible to do so in a line.
$s = "a,b,c,d"; $qs = "'".implode("','",explode(",",$s))."'";
Tags: php
- sugree's blog
- 2425 reads
Recent comments
2 years 11 weeks ago
2 years 15 weeks ago
2 years 16 weeks ago
2 years 16 weeks ago
2 years 17 weeks ago
2 years 19 weeks ago
2 years 19 weeks ago
2 years 19 weeks ago
2 years 19 weeks ago
2 years 20 weeks ago