php - Cutting out scraped dates and grouping by day? -


i use following scrape soccer fixtures site...

// retrieve url $url = 'http://fantasy.mlssoccer.com/fixtures/'; $html = @file_get_html($url);  //cuts out table $fullfixtable = $html->find('table[class=ismfixturetable]',0);  // find results , break them pieces foreach($fullfixtable->find('tr[class=ismfixture]') $resultstocutout)  {     $gamedate = $resultstocutout->find('td',0)->innertext;       $date = substr($gamedate, 0, 6);       $time = substr(substr($gamedate, 0, -4), (strlen(substr($gamedate, 0, -6))-5)*-1);     $hometeam = $resultstocutout->find('td',1)->innertext;     $awayteam = $resultstocutout->find('td',5)->innertext;      echo $date.' '.$time.' '.$hometeam.' v '.$awayteam.'<br>'; } 

this echoes....

may 15 7:30pm philadelphia union v los angeles galaxy may 18 5:00pm toronto fc v columbus crew may 18 7:00pm vancouver whitecaps v portland timbers may 18 7:30pm philadelphia union v chicago fire may 18 8:30pm houston dynamo v new england revolution may 18 10:30pm san jose earthquakes v colorado rapids may 18 10:30pm seattle sounders fc v fc dallas may 19 1:00pm new york red bulls v los angeles galaxy may 19 5:00pm d.c. united v sporting kansas city may 19 10:30pm chivas usa v real salt lake 

which fine... want information in order....

may 15   7:30pm philadelphia union v los angeles galaxy may 18   5:00pm toronto fc v columbus crew   7:00pm vancouver whitecaps v portland timbers   7:30pm philadelphia union v chicago fire   8:30pm houston dynamo v new england revolution   10:30pm san jose earthquakes v colorado rapids   10:30pm seattle sounders fc v fc dallas may 19   1:00pm new york red bulls v los angeles galaxy   5:00pm d.c. united v sporting kansas city   10:30pm chivas usa v real salt lake 

any idea how that? know can use substr cut stuff out, have no idea how group similar date. dates m d g:ia t format, there's far easier , better way cut out way used above.

thanks suggestions.

this should it:

if ( !isset($lastdate) || $date !== $lastdate ) {     echo $date.'<br>';     echo $time.' - '.$hometeam.' v '.$awayteam.'<br>';     $lastdate = $date; } else {     echo $time.' - '.$hometeam.' v '.$awayteam.'<br>'; } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -