修改数组以使值附加单引号

时间:2022-06-01 20:09:01

How would I modify an array in php from:

我如何修改php中的数组:

$colors = [red, green, blue]

To having single quotes around each value:

要在每个值周围加上单引号:

$colors = 'red', 'green', 'blue'

1 个解决方案

#1


1  

Something on the lines of $colors = "'" . implode("', '", $colors) . "'"; would help you out in this situation.

$ colors =“'”的行。 implode(“','”,$ colors)。 “'”;在这种情况下会帮助你。

#1


1  

Something on the lines of $colors = "'" . implode("', '", $colors) . "'"; would help you out in this situation.

$ colors =“'”的行。 implode(“','”,$ colors)。 “'”;在这种情况下会帮助你。