I'm trying to add new PHP Objects to an Array inside a Class. It works for 2 entries but then after adding 1 more the whole array gets destructed.
public $players = array();
This is the Code where I add the new PHP Objects:
/*
* $data[0] => GameUserID
* $data[1] => SlotID (In Game, INT)
* $data[2] => GameUserName
* $this => I've made a function called log($str) in the Main class, so I can
* class this Function in the Player Class later
*/
$this->log("Creating new player on SlotID #".$data[1]);
$tmp = new Player($data[0], $data[2], $this);
$this->players[$data[1]] = &$tmp;
unset($tmp);
//$this->players[$data[1]] = new Player($data[0], $data[2], $this);
The Class "Player" does not return anything on __construct().
I can't find the fail I make.
==============
I found out that the variable isn't saving after the function was called (reached the end). It's empty again whenever I call the function again.