Asked 3 years ago
30 Jul 2021
Views 948
Melba

Melba posted

How to convert Array to string in PHP without using implode method

How to convert Array to string in PHP without using implode method
Melyna

Melyna
answered Aug 22 '21 17:31

want convert Array to string in PHP without using implode method then use join() function

join() function is can convert the array to string in PHP.


$a=array("a",,"b""c","d");
echo join(" ",$array); 


join("first argument is glue","second argument must be array ")

so in above we glued the array value with one space and make a string in returns with join() function in PHP

join() function is alias of the implode() function in PHP


if you want to convert array to JSON string .

json_encode() function will encode array to JSON, JSON is one type of string which formatted so it can convert JSON string to array again.

$response=array("stauts"=>"1");
echo json_encode($response);


JSON format is used to information exchange between server to server or server to client
Server Ajax response will be sent back to the browser in the format of JSON
Post Answer