Skip to content

Instantly share code, notes, and snippets.

@mdahlke
Created January 10, 2017 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdahlke/5d8d452d8258136b70b0744da35f7a87 to your computer and use it in GitHub Desktop.
Save mdahlke/5d8d452d8258136b70b0744da35f7a87 to your computer and use it in GitHub Desktop.
Implode an associative array on specified key
function implode_aa( $glue, $array, $key ) {
$keep = array();
foreach ( $array as $firstKey ) {
foreach ( $firstKey as $k => $v ) {
if ( $k === $key ) {
$keep[] = $v;
}
}
}
return implode( $glue, $keep );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment