PHP code example of lakshay / converter

1. Go to this page and download the library: Download lakshay/converter 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/ */

    

lakshay / converter example snippets


    // include the composer autoloader
    use Lakshay\Converter\Standard\RIS\RIS;
    use Lakshay\Converter\Standard\BibTeX\BibTeX;
    use Lakshay\Converter\Standard\CSL\CSL;

    $converter  =   new Converter();

    // your input RIS data
    $data = 'TY  - JOUR
             TI  - Die Grundlage der allgemeinen Relativitätstheorie
             AU  - Einstein, Albert
             PY  - 1916
             SP  - 769
             EP  - 822
             JO  - Annalen der Physik
             VL  - 49
             ER  - ';

    // convert to bibTeX
    $bibTeX =   $converter->convert(new RIS($data), new BibTeX());

    /**
     * $bibTeX now has the following value:
     *
     * @article{article,
     *      author = {Einstein, Albert},
     *      year = {1916},
     *      pages = {769-822},
     *      title = {Die Grundlage der allgemeinen Relativitätstheorie},
     *      volume = {49}
     * }
     */

     // or convert bibTeX to csl
     $csl   =   $converter->convert(new BibTeX($bibTeX), new CSL());

     /**
      * $csl now has the following value (a UTF-8 encoded json string):
      *
      * [
      *     {
      *         "type":"article",
      *         "author":[{
      *             "family":"Einstein",
      *             "given":"Albert"
      *         }],
      *         "issued":[{
      *             "year":"1916"
      *         }],
      *         "page":"769-822",
      *         "page-first":"769",
      *         "citation-label":"article",
      *         "title":"Die Grundlage der allgemeinen Relativit\u00e4tstheorie"
      *     }
      * ]
      */