douying4203
2019-02-14 13:30
浏览 86
已采纳

将数组分隔为逗号分隔的字符串

I want to separate my array into separate strings that all end with a comma.

Array ( [0] => 233d3f9b-3e8e-4e16-ade2-6c165a0324c6 
        [2] => a6c736b0-f3d2-4907-9d36-6b31adeec2d1 
        [3] => 1e693cba-d0ce-4a24-bd75-b834e3f44272 
    )

The purpose of this is so i can pass it to an API. Like this

    'optionUuids' => array(
        $options2,
    ),

The option UUidds can contain multiple values as long its separated by a comma in the end.

I tried solving my problem using implode. Implode adds a comma at the end of each line, but it treats this comma as a string. I want to have multiple option UUids so i would need commas that are actually commas and not strings.

Im having trouble explaining this. This is what i expect:

    'optionUuids' => array(
      233d3f9b-3e8e-4e16-ade2-6c165a0324c6,
      a6c736b0-f3d2-4907-9d36-6b31adeec2d1,
      1e693cba-d0ce-4a24-bd75-b834e3f44272,
    ),

2条回答 默认 最新

相关推荐 更多相似问题