如何将php数组与对象转换为简单数组?

I have a function that returns an array like this

Array
(
    [0] => stdClass Object
        (
            [tid] => 1
            [vid] => 2
            [name] => About Us
            [description] => 
            [format] => wysiwyg_editor
            [weight] => 0
            [depth] => 0
            [parents] => Array
                (
                    [0] => 0
                )

        )

[1] => stdClass Object
    (
        [tid] => 200
        [vid] => 2
        [name] => Stories
        [description] => 
        [format] => wysiwyg_editor
        [weight] => 0
        [depth] => 0
        [parents] => Array
            (
                [0] => 0
            )

    )

)

To simplify it for further use I would like to convert this array into simple one with keys as [tid] and values as [name] So it would be smth like this:

Array
(
    [1] => About Us
    [200] => Stories

)

Any tips or help with proper code syntax would be great. Thanks

Try this:

$result = array();
foreach ($data as $row) {
    $result[$row->tid] = $row->name;
}
var_dump($result);

use this snippet :

function transform($arr){
   $result = array();

   foreach($arr as $obj){
     $result[$obj->tid] = $obj->name;
   }

   return $result;
}