phonenumbers[] = $phone; $phone->user = $this; } public function removePhonenumber($index) { if (isset($this->phonenumbers[$index])) { $ph = $this->phonenumbers[$index]; unset($this->phonenumbers[$index]); $ph->user = null; return true; } return false; } }