PHP code example of risendy / pgn-parser-bundle

1. Go to this page and download the library: Download risendy/pgn-parser-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

risendy / pgn-parser-bundle example snippets


$game = new ChessParser();
$game->parsePgn($pgn);

$json = $game->createJsonArray();

result:
{
   "tags":{
      "Event":"Lets Play!",
      "Site":"Chess.com",
      "Date":"2018.12.04",
      "Round":"?",
      "White":"guilherme_1910",
      "Black":"bmbio",
      "Result":"0-1",
      "TimeControl":"1\/259200:0"
   },
   "moves":[
      {
         "moveNumber":1,
         "white":"e4",
         "black":"e6"
      },
      {
         "moveNumber":2,
         "white":"d4",
         "black":null
      }
   ]
}