I have an array like this:
$Array = [
[1, 33, 55, 18],
[8, 9, 12, 67],
[3, 33, 76, 88],
];
And I want add ; to output like this:
1, 33, 55, 18;
8, 9, 12, 67;
3, 33, 76, 88
Anyone know how to do this?
I have an array like this:
$Array = [
[1, 33, 55, 18],
[8, 9, 12, 67],
[3, 33, 76, 88],
];
And I want add ; to output like this:
1, 33, 55, 18;
8, 9, 12, 67;
3, 33, 76, 88
Anyone know how to do this?
Use array map to achieve this
$temp = array_map(function($item){
return implode(", ", $item);
}, $Array);
foreach($temp as $v){
// implode with ';' and \n for line break
// you can use "<br/>" if you are using web.
echo $v.";\n";
}
Demo.
One looper:
foreach($Array as $v){
echo implode(", ",$v).";\n";
}
Demo.
Output
1, 33, 55, 18;
8, 9, 12, 67;
3, 33, 76, 88;