Is it possible to delete an object's property in PHP? -


if have stdobject say, $a.

sure there's no problem assign new property, $a,

$a->new_property = $xyz; 

but want remove it, unset of no here.

so,

$a->new_property = null; 

is kind of it. there more 'elegant' way?

unset($a->new_property); 

this works array elements, variables, , object attributes

** edit **

i don't know how using unset(), how works me :

$a = new stdclass();  $a->new_property = 'foo'; var_export($a);  // -> stdclass::__set_state(array('new_property' => 'foo'))  unset($a->new_property); var_export($a);  // -> stdclass::__set_state(array()) 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -