I have to create string like $zn = "43,49,57,3,68,69";
from following array without using loop :
Array
(
[0] => Array
(
['pk_id'] => 43
),
[1] => Array
(
['pk_id'] => 49
),
[2] => Array
(
['pk_id'] => 57
),
[3] => Array
(
['pk_id'] => 3
),
[4] => Array
(
['pk_id'] => 68
),
[5] => Array
(
['pk_id'] => 69
)
);
What are the ways I can do?
It should take less time and memory.
use array_column with implode function in php
implode(',',array_column($a, 'pk_id'));
You can use array_walk_recursive
function:
$result = array();
array_walk_recursive($arr, function($v) use (&$result) {
$result[] = $v;
});
echo implode('&', $result);
Read more about array_walk_recursive.