public function getPlayers() { $statsTable = $this->scraper->find('.stats tbody tr'); foreach ($statsTable as $key => $player) { $td = $player->children(); if ($key > 0) { $playerObj = new stdClass(); $playerObj->name = $td[1]->plaintext; $playerObj->team = $td[2]->plaintext; $playerObj->position = $td[3]->plaintext; $playerObj->games_played = intval($td[4]->plaintext); $playerObj->goals = intval($td[5]->plaintext); $playerObj->assists = intval($td[6]->plaintext); $playerObj->points = intval($td[7]->plaintext); $playerObj->plus_minus = intval($td[8]->plaintext); $playerObj->pims = intval($td[9]->plaintext); $playerObj->ppg = intval($td[10]->plaintext); $playerObj->ppp = intval($td[11]->plaintext); $playerObj->shg = intval($td[12]->plaintext); $this->database->insertPlayers($playerObj); $this->database->insertPlayerStats($playerObj); $this->results[] = $playerObj; } } sleep(10); // echo json_encode($players); } } $scraper = new Players(); $scraper->run();