$ Data array
$ data = array ( 'John Doe', 'M', '20 ',' Hefei ');
converted as follows:
#join
. STR $ = "'" the Join ( " ''", array_values ($ data)) " '"; // need to use symbols splicing.
#str_replace
$ STR = "'" .str_replace ( ",", " ','", the implode ( ',', $ Data)); // use Alternatively the required symbols
#array_map functional achieved
$ str = join ( ',' , array_map (function ($ v) {return " '" "" $ v..';}, $ data)); // use the function splice
results: 'John Doe', 'male', '20', '' Hefei ';
----------------
Disclaimer: This article is CSDN bloggers' youcijibi " the original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/youcijibi/article/details/81015004