Feels like it should be easy...
function flattenTags($t) {
return ($t['name']);
}
$tags = array($Fan->getTags());
$flat_tags = array_map('self::flattenTags', $tags);
$string_tags = join(', ', $flat_tags);
where tags
is an array of objects each with multiple properties.
Error:
Cannot use object of type yii\\db\\ActiveQuery as array
In JS this is a simple array.map().join()
. Can't get it to work with PHP. Please help!
EDIT: do I need some kind of await like JS?