Skip to content

Instantly share code, notes, and snippets.

@xintron
Created December 11, 2012 09:27
Show Gist options
  • Save xintron/4257284 to your computer and use it in GitHub Desktop.
Save xintron/4257284 to your computer and use it in GitHub Desktop.
<?php
$url = 'http://www.trafiken.nu/TrafikenServices/TraveltimeService.ashx?method=getTraveltime&region=VST&sectionId=3001';
$c = curl_init($url);
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('Content-type: application/json')
);
curl_setopt_array($c, $options);
$data = curl_exec($c);
function findSectionId($sectionId, $data) {
preg_match_all("/({\"sectionId\":\"$sectionId\".*?})/", $data, $m, PREG_SET_ORDER);
return $m;
}
$d = findSectionId(30001, $data);
foreach ($d as $row)
echo $row[0];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment