How to convert an array to a string in PHP?

前端 未结 8 912
[愿得一人]
[愿得一人] 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 15:02

    PHP has a built-in function implode to assign array values to string. Use it like this:

    $str = implode(",", $array);
    
    0 讨论(0)
  • 2021-02-01 15:11
    implode(' ',$array);
    
    0 讨论(0)
提交回复
热议问题