Reputation: 425
how i can get "name" from array in foreach loop?
This is my array:
Array
(
[0] => Array
(
[term_id] => 2
[name] => test1
)
[1] => Array
(
[term_id] => 13
[name] => test2
)
[2] => Array
(
[term_id] => 22
[name] => test3
)
[3] => Array
(
[term_id] => 19
[name] => test4
)
)
i tried with foreach:
foreach ($tags as $get){
$array[] = array('new' => $get[0]->name);
}
but not work, my question is: how to get value name from this array?
Upvotes: 0
Views: 69
Reputation: 12246
You are very close:
foreach ($tags as $get){
$array[] = array('new' => $get['name']);
}
Upvotes: 2
Reputation: 31749
Try with -
foreach ($tags as $get){
$array[] = array('new' => $get['name']);
}
Upvotes: 3