I need to remove an object from an array in php but I need the object reference to still exist, when I tried using unset() as described here it unset both the array element and the object itself, how can I remove the reference from the array without destroying the object?
my code looks like the following:
$this->array[id] = myobject;
unset($this->array[$id]);
unset($arr[5]); // This removes the element from the arrayso in your caseunset($this[$id]);should remove the item from the $this array (badly define object array using $this as the array name). can you post your proper code not the example above lets see the whole class and constructs etc so we can see what exactly your trying to do. I suspect its not an unset() issue but more of your syntax issue$this[id]doesn't really work.$thisis preoccupied. Do you mean$this->array[id] = myobject;?