Object's property containing array doesn't let me unset it

时间:2019-01-18 19:06:36

标签: php arrays laravel object

I am crazy confused by this object's properties behavior.

$userChangesLog->newData->login = 0;
$userChangesLog->newData->interests = 0;

var_dump($userChangesLog->newData->login);
var_dump($userChangesLog->newData->interests);

First var_dump of login gives me output:

int(0)

The second var_dump of interests gives me output:

array(7) { [0]=> array(3) { ["id"]=> int(0) ["name"]=> string(6) "Movies" ["interests"]=> array(0) { } } [1]=> array(3) { ["id"]=> int(1) ["name"]=> string(5) "Sport" ["interests"]=> array(0) { } } [2]=> array(3) { ["id"]=> int(2) ["name"]=> string(10) "Literature" ["interests"]=> array(0) { } } [3]=> array(3) { ["id"]=> int(3) ["name"]=> string(5) "Games" ["interests"]=> array(0) { } } [4]=> array(3) { ["id"]=> int(4) ["name"]=> string(3) "Job" ["interests"]=> array(0) { } } [5]=> array(3) { ["id"]=> int(5) ["name"]=> string(5) "Music" ["interests"]=> array(0) { } } [6]=> array(3) { ["id"]=> int(6) ["name"]=> string(24) "Family and relationships" ["interests"]=> array(0) { } } }

I have also tried make it null or use unset() method but nothing helps to remove this array from interests property.

Is there any reason of why this happens?

0 个答案:

没有答案