I am new to PHP.
I want to convert this array [["14785"],["125478"]] to string like this 14785,125478.
What is the way to do this?
I am new to PHP.
I want to convert this array [["14785"],["125478"]] to string like this 14785,125478.
What is the way to do this?
try this,
Using implode()
- Demo
$array = ["14785"],["125478"]
$str = implode(',',$array);
echo $str;
Using join()
- Demo
$array = ["14785","125478"];
$str = join(",",$array);
echo $str;
EDIT
For multi-dimention array, - Demo
$arr = [["14785"],["125478"]];
$str = implode(',', array_map(function($el){ return $el[0]; }, $arr));
echo $str;
use php's implode
function
$arr = ["14785","125478"];
echo implode(",",$arr);
Using implode()
<?php
$arr = array('Hello','World!','Beautiful','Day!');
echo implode(" ",$arr);
?>