How to convert an array to a string in PHP?

前端 未结 8 937
[愿得一人]
[愿得一人] 2021-02-01 14:42

For an array like the one below; what would be the best way to get the array values and store them as a comma-separated string?

Array ( [0] => 33160,
                 


        
8条回答
  •  遥遥无期
    2021-02-01 14:48

    I would turn it into a json object, with the added benefit of keeping the keys if you are using an associative array:

     $stringRepresentation= json_encode($arr);
    

提交回复
热议问题