Combining two foreach without errors

I have a simple html dom query which read informations from a football fixtures source, and I loading also a json source.

Here is my full code:

    header('Content-Type: text/html; charset=utf-8');
    ini_set("user_agent", "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.60 Safari/537.17");


    ini_set('display_errors', true);

    $str = file_get_contents('general.json');

    $json = json_decode($str,true);

        $filename = "source.html";
        $html = file_get_html($filename);

    class matches {
        var $day;
        var $kickofftime;
            var $result;

        function matches ($day, $kickofftime, $result){
            return $this;


    $day=str_replace("<h1>TODAY FOOTBALL FIXTURES: ","", $day);
    $day=str_replace("</h1>","", $day);
    $matchday = str_replace(array('MONDAY ', 'TUESDAY ', 'WEDNESDAY ', 'THURSDAY ', 'FRIDAY ',  'SATURDAY ',  'SUNDAY '), '', $day);
    $matchday=str_replace(" ","-", $matchday);
    $matchday=date('Y-m-d', strtotime($matchday));

    foreach($html->find('table.fixtures') as $matches) 


        foreach ($matches->find('tr[class=a1],tr[class=a2]') as $matchesTR) {

    $kodate = date('Y-m-d H:i:s', strtotime("$matchday $kickofftime +1 hour"));

    echo $kodate;
    echo $result[6]->plaintext.'<br>' ; 



//Here is the 2nd foreach with the data of JSON source:

    foreach($json as $key => $value) {

    $value = json_decode($value, true);

    echo $value["country"] . ", " . $value["competition"] . "  " . $value["club"] . "<br>";

    // clean up memory


The current results from the simple html dom html source:

2014-12-23 20:00:00 2-1
2014-12-23 11:00:00 3-1
2014-12-26 08:00:00 1-1

The result from the JSON source:

America Copa America Boca Juniors
Europe Bundesliga Hannover
Asia JLeague Nagoya

I would like to combine these two results in one foreach and I would like to get this result:

2014-12-23 20:00:00 2-1 America Copa America Boca Juniors
2014-12-23 11:00:00 3-1 Europe Bundesliga Hannover
2014-12-26 08:00:00 1-1 Asia JLeague Nagoya

I hope that there is some expert who can help for me because I tried a lot of variation but without result. Many thanks!

Source: json

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.