I have one index array which contain associative array. Like this
$arr = array(
array("id" => 1,"name" => "student1"),
array("id" => 2,"name" => "student2"),
array("id" => 3,"name" => "student3"),
);
Now I want output like this
1,2,3 // output
I have solution for it but I am searching for better way to do that. Here it is
$ids = "";
for($i=0;$i<count($arr);$i++)
{
$ids .= $arr[$i]['id'].",";
}
$ids = rtrim($ids,",");
echo $ids; // output : 1,2,3
Is there any better way to achieve it?
Thanks in advance