public function friends($playerID = null) { if (!$_POST) { throw new NinjaException("Error receiving data " . $playerID); } $playerModel = new PlayerModel(); $data = json_decode($_POST['data']); $data = $_POST['friends']['data']; foreach ($data as $friend) { $friendData = $playerModel->getFriendData($friend['id']); if ($friendData) { $friends[] = $friendData; } } $this->printJson($this->printJson($friends)); }