PHP code example of derickr / gpx-utils

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

    

derickr / gpx-utils example snippets


		
	use DerickR\GPX\Reader;

	$gpxInformation = new Reader( $file );
	

	
	use DerickR\GPX\Writer;

	$writer = new Writer( $track );
	$writer->writeGpx( 'route-test.gpx' );
	

	
	use DerickR\GPX\Writer;

	$writer = new Writer( $track );
	$xmlString = $writer->getGpxString();
	

	
	use DerickR\GPX\Reader;
	use DerickR\GPX\Utils;
	use DerickR\GPX\Writer;

	// Find all .gpx files
	$files = glob( '*.gpx' );

	// Read all tracks into an array
	$tracks = [];
	foreach ( $files as $file )
	{
		$tracks[] = (new Reader( $file ))->getTrack();
	}

	// Merge all tracks into a single one.
	$track = Utils::createMergedTrack( $tracks );

	// Write created track to a file
	$writer = new Writer( $track );
	$writer->writeGpx( 'route-test.gpx' );