From ddeb4e8510e50b40a879cb67041fb8802cf0cd0d Mon Sep 17 00:00:00 2001 From: DHTMLGoodies Date: Thu, 17 Aug 2017 14:36:12 +0200 Subject: [PATCH] bugfix - to short version - skipping comment moves --- PgnParser.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/PgnParser.php b/PgnParser.php index 24a57c8..7e6b812 100755 --- a/PgnParser.php +++ b/PgnParser.php @@ -202,20 +202,24 @@ class PgnParser private function toShortVersion($branch) { foreach ($branch as &$move) { - $move["n"] = $move["from"] . $move["to"]; - #$move["n"] = $move["from"] . $move["to"]; - #unset($move["m"]); - unset($move["fen"]); - unset($move["from"]); - unset($move["to"]); - if (isset($move["variations"])) { - $move["v"] = array(); - foreach ($move["variations"] as $variation) { - $move["v"][] = $this->toShortVersion($variation); + if (isset($move["from"])) { + $move["n"] = $move["from"] . $move["to"]; + + #$move["n"] = $move["from"] . $move["to"]; + #unset($move["m"]); + unset($move["fen"]); + unset($move["from"]); + unset($move["to"]); + if (isset($move["variations"])) { + $move["v"] = array(); + foreach ($move["variations"] as $variation) { + $move["v"][] = $this->toShortVersion($variation); + } } + unset($move["variations"]); } - unset($move["variations"]); + } return $branch; }