php add single or double quotes to each element in the array to share

php adds single or double quotes to each element in the array. E.g:

 $array = [1, 2];

Now the array needs to be changed to:

 $arr = ['1', '2'];

Operation method:

$new_array = array_map(function ($value) {     return ''' . $value . '''; }, $array);

For related knowledge of array_map, please refer to:

PHP array function array_map() notes

Posted in: PHP

Leave a Reply

Your email address will not be published.

en_USEnglish