array to string conversion php code example
Example 1: string to array in php
print_r(explode(',',$yourstring));
Example 2: Array to String Conversion in PHP
$gadget = array( 'computer', 'mobile', 'tablet' );
echo implode($arr);
Example 3: 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 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: php array to string
$str = implode('|', $arr);
$str = json_encode($arr);
$str = var_export($arr);