query('//game[@id="' . $id . '"]')->item(0); $game->parentNode->removeChild($game); $count = $doc->getElementsByTagName("count")->item(0); $icount = intval($count->nodeValue) - 1; $count->nodeValue = $icount; [$data, $_] = get_data(); $i = 1; foreach($data as $d) { if($d["id"] === $id) continue; $g = $xpath->query('//game[@id="' . $d["id"] . '"]')->item(0); var_dump('//game[@id="' . $d["id"] . '"]'); $g->setAttribute("order", $i); $i++; } $doc->save($path); header("Location: " . $_SERVER["HTTP_REFERER"]);