从数组中获取值名称

Get value name from array

如何在 foreach 循环中从数组中获取 "name"?

这是我的数组:

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
        )

)

我试过 foreach:

foreach ($tags as $get){
    $array[] = array('new' => $get[0]->name);
}

但不起作用,我的问题是:如何从这个数组中获取值名称?

试试 -

foreach ($tags as $get){
    $array[] = array('new' => $get['name']);
}

你们很亲近:

foreach ($tags as $get){
    $array[] = array('new' => $get['name']);
}