Array to string conversion code example
Example 1: Array to String Conversion in PHP
$gadget = array( 'computer', 'mobile', 'tablet' );
echo implode($arr);
Example 2: 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 3: convert integer array to string array
int[] nums = {5,1,2,11,3};
Arrays.sort(nums);
String a=Arrays.toString(nums);
String ar[]=a.substring(1,a.length()-1).split(", ");
System.out.println(Arrays.toString(ar));
Example 4: array to string conversion in php
$person = [
'name' => 'Jon',
'age' => 26,
'status' => null,
'friends' => ['Matt', 'Kaci', 'Jess']
];
echo json_encode($person);
Example 5: Notice: Array to string conversion php
$stuff = array(1,2,3);
print json_encode($stuff);
Example 6: Notice: Array to string conversion php
$stuff = array(1,2,3);
print_r($stuff);
$stuff = array(3,4,5);
var_dump($stuff);