array convert to string in php code example
Example 1: php Array to string conversion
Using implode() function in Php
-----------------------
Syntax
implode(separator,array);
Example
<?php
$dummyArr = array("Hello","Greppers,","Ankur","here !");
echo implode(" ",$dummyArr);
?>
Output:
Hello Greppers, Ankur here !
Example 2: Array to String Conversion in PHP
$gadget = array( 'computer', 'mobile', 'tablet' );
echo implode($arr);
Example 3: php implode
$arr = array('Hello','World!','Beautiful','Day!');
echo implode(" ",$arr);
Example 4: Convert an Array to a String in PHP
phpCopy<?php
$array = ["Lili", "Rose", "Jasmine", "Daisy"];
$JsonObject = serialize($array);
echo "The array is converted to the Json string.";
echo "\n";
echo"The Json string is $JsonObject";
?>