elegant way to extract values from array
- by smoove666
Something that bugs me for a long time:
I want to convert this Array:
// $article['Tags']
array(3) {
[0] => array(2) {
["id"] => string(4) "1"
["tag"] => string(5) "tag1"
},
[1] => array(2) {
["id"] => string(4) "2"
["tag"] => string(5) "tag2"
},
[2] => array(2) {
["id"] => string(4) "3"
["tag"] => string(5) "tag3"
},
}
To this form:
// $extractedTags[]
array(3) {
[0] => string(4) "tag1",
[1] => string(4) "tag2",
[2] => string(4) "tag3",
}
currently i am using this code:
$extractedTags = array();
foreach ($article['Tags'] as $tags) {
$extractedTags[] = $tags['tag'];
}
Is there any more elegant way of doing this, maybe a php built-in function?