array convert to string php code example
Example 1: array to string conversion in php
$person = [
'name' => 'Jon',
'age' => 26,
'status' => null,
'friends' => ['Matt', 'Kaci', 'Jess']
];
echo json_encode($person);
Example 2: arry to string php
implode("|",$type);
Example 3: array to string conversion in php
function subArraysToString($ar, $sep = ', ') {
$str = '';
foreach ($ar as $val) {
$str .= implode($sep, $val);
$str .= $sep;
}
$str = rtrim($str, $sep);
return $str;
}
echo subArraysToString($food);