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: php implode
$arr = array('Hello','World!','Beautiful','Day!');
echo implode(" ",$arr);
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: php array to string
$str = implode('|', $arr);
$str = json_encode($arr);
$str = var_export($arr);
Example 6: arry to string php
implode("|",$type);
Comments
Post a Comment