How to convert array to a string using methods other than JSON?

后端 未结 8 2141
臣服心动
臣服心动 2020-12-01 13:32

What is a function in PHP used to convert array to string, other than using JSON?

I know there is a function that directly does like JSON. I just don\'t remember.

8条回答
  •  情深已故
    2020-12-01 14:02

    Use the implode() function:

    $array = array('lastname', 'email', 'phone');
    $comma_separated = implode(",", $array);
    echo $comma_separated; // lastname,email,phone
    

提交回复
热议问题