Code: Select all
$gcsite = file_get_contents("http://gcp.djbradanderson.com/gcpindex.php");
$gcsite_display = substr($gcsite, 48, 45);Tom
Moderator: General Moderators
Code: Select all
$gcsite = file_get_contents("http://gcp.djbradanderson.com/gcpindex.php");
$gcsite_display = substr($gcsite, 48, 45);Code: Select all
$gcsite = (integer) $gcsite;Code: Select all
<?php
$gcsite = file_get_contents("http://gcp.djbradanderson.com/gcpindex.php");
$gcsite_display = substr($gcsite, 48, 45);
var_dump($gcsite_display);
?>and <seconds> is not a numerical valuestring(45) "<seconds><second time='1160600340'>0.4869</se"
Can you use a xml extension for php to parse the document?<gcpstats>
<serverTime>1160600306</serverTime>
<seconds><second time='1160600280'>0.9339</second><second time='1160600281'>0.9283</second><second time='1160600282'>0.9291</second><second time='1160600283'>0.9341</second><second time='1160600284'>0.9341</second><second time='1160600285'>0.9344</second><second time='1160600286'>0.9360</second><second time='1160600287'>0.9373</second><second time='1160600288'>0.9394</second><second time='1160600289'>0.9393</second><second time='1160600290'>0.9396</second><second time='1160600291'>0.9412</second><second time='1160600292'>0.9398</second><second time='1160600293'>0.9332</second><second time='1160600294'>0.9319</second><second time='1160600295'>0.9314</second><second time='1160600296'>0.9317</second><second time='1160600297'>0.9317</second><second time='1160600298'>0.9309</second><second time='1160600299'>0.9315</second><second time='1160600300'>0.9316</second><second time='1160600301'>0.9241</second><second time='1160600302'>0.9245</second><second time='1160600303'>0.9226</second><second time='1160600304'>0.9214</second><second time='1160600305'>0.9281</second><second time='1160600306'>0.9281</second><second time='1160600307'>0.9268</second><second time='1160600308'>0.9239</second><second time='1160600309'>0.9240</second><second time='1160600310'>0.9243</second><second time='1160600311'>0.9235</second><second time='1160600312'>0.9177</second><second time='1160600313'>0.9180</second><second time='1160600314'>0.9187</second><second time='1160600315'>0.9170</second><second time='1160600316'>0.9107</second><second time='1160600317'>0.9099</second><second time='1160600318'>0.9052</second><second time='1160600319'>0.9044</second><second time='1160600320'>0.9047</second><second time='1160600321'>0.9044</second><second time='1160600322'>0.9035</second><second time='1160600323'>0.5201</second><second time='1160600324'>0.5204</second><second time='1160600325'>0.5251</second><second time='1160600326'>0.5188</second><second time='1160600327'>0.5158</second><second time='1160600328'>0.5167</second><second time='1160600329'>0.9008</second><second time='1160600330'>0.4799</second><second time='1160600331'>0.4908</second><second time='1160600332'>0.4938</second><second time='1160600333'>0.4917</second><second time='1160600334'>0.4891</second><second time='1160600335'>0.4899</second><second time='1160600336'>0.4927</second><second time='1160600337'>0.4930</second><second time='1160600338'>0.4907</second><second time='1160600339'>0.4942</second></seconds></gcpstats>
http://gcp.djbradanderson.com/gcpindex.php wrote:Code: Select all
<gcpstats> <serverTime>1160600068</serverTime> <seconds><second time='1160600040'>0.9397</second><second time='1160600041'>0.9393</second><second time='1160600042'>0.9368</second><second time='1160600043'>0.9400</second> [......] <second time='1160600097'>0.9301</second><second time='1160600098'>0.9313</second><second time='1160600099'>0.9317</second></seconds></gcpstats>
Code: Select all
<?php
$gcsite = file_get_contents("http://gcp.djbradanderson.com/gcpindex.php");
$pattern = '!<second time=\'(\d+)\'>([0-9.]+)</second>!';
preg_match_all($pattern, $gcsite, $matches);
echo $matches[1][0], ' | ', $matches[2][0];
?>