如何使用foreach过滤对象

I would like to delete some informations in my object from the key.

Is it possible to do something likes that:

foreach ( $object AS $key => $value ) {

    if ( $key == "abc" ) {

        unset( $object{ $key } );

    }

}

When I try it I have:

Cannot use object of type stdClass as array

Thx

foreach ($object as $key => $value)
{
    if ($key === "abc") 
    {
        unset($object->key);
    }
}

Although seeing as you know the key (based on your "if") you could just do this:

unset($object->abc);