I've got associative array with results from database containing data like in following structure:
$arr[0] = Array("id"=>4, "otherdata"=>"something");
$arr[1] = Array("id"=>6, "otherdata"=>"something else");
$arr[2] = Array("id"=>15, "otherdata"=>"something totally different");
I would like to implode data that is only in id
key for each $arr
entry, so that final imploded string is 4,6,15
(gluded with ,
).
Right now I've got some solutions:
- Doing it in pure PHP within Smarty.
- Creating function that will implode result from array_map which creates new table with id's only.
- Assigning variable within Smarty template and creating implode-like result string with foreach.
but neither of them I am happy of.
Is there any other simple way to achieve desired result?