PHP's native implode function is quite useful in many cases, but there comes a time where you need to implode a specific key's value. Here is a function which will allow you to do just that.

The Code:Edit

function implode_by_key($glue, $keyname, $pieces) {
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($pieces));
$arr = array();
foreach($it AS $element) {if($it->key() == $keyname) {$arr[] = $it->current();}}
return implode($glue, $arr);

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.