PHP code example of phaza / norwegian-ssr-parser

1. Go to this page and download the library: Download phaza/norwegian-ssr-parser 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/ */

    

phaza / norwegian-ssr-parser example snippets


#!PHP

  
use Phaza\SSR\Feature;
use Phaza\SSR\Listener;

$handle = fopen('Stedsnavn.geojson', 'r');

$listener = new Listener(function(Feature $item) {
	/* Do your magic in the closure */
});
$parser = new JsonStreamingParser_Parser($handle, $listener);
$parser->parse();

fclose($handle);

#!PHP


$handle = fopen('Stedsnavn.bz2', 'r');
stream_filter_append($handle, 'bzip2.decompress', STREAM_FILTER_READ);
$parser = new JsonStreamingParser_Parser($handle, $listener);
fclose($handle);

// pr

$handle = fopen('compress.bzip2://Stedsnavn.bz2', 'r');
$parser = new JsonStreamingParser_Parser($handle, $listener);
fclose($handle);