1$array = array('banana', 'strawberry', 'apple');
2comma_separated = implode(",", $array);
3echo comma_separated; // banana,strawberry,apple
1phpCopy<?php
2 $array = ["Lili", "Rose", "Jasmine", "Daisy"];
3 $JsonObject = json_encode($array);
4 echo "The array is converted to the Json string.";
5 echo "\n";
6 echo"The Json string is $JsonObject";
7?>
8
1$arr = array('Hello','World!','Beautiful','Day!');
2echo implode(" ",$arr);
3// Outputs: 'Hello World! Beautiful Day!'
1// for one-dimentional arrays
2$str = implode('|', $arr); // "v1|v2|v3"...
3
4// for multi-dimensional/structured arrays, or to keep hierarchy
5$str = json_encode($arr);
6// or
7$str = var_export($arr);