how can I combine my received json datas with my existing simple html dom query

I received json datas with the ajax post method. (The sample format what I receiving from tomorrow.php: POSTDATA=country=America&competition=Copa+Libertado&team=Boca+Juniors , content type = application/json, charset utf-8 ) via tomorrow.php at my simple html dom query file. I receive multiple json datas, so not just one POSTDATA. I would like to convert all datas to php variables. How can I do this? And How can I combine with my existing simple_html_dom query?

My existing simple html dom query (I included tomorrow.php which send the json datas with county, competition, and club)

<?php
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");

include ("tomorrow.php");
include ("mysql.php");
include_once('simple_html_dom.php');

ini_set('display_errors', true);
error_reporting(E_ALL);

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

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

        function matches ($day, $kickofftime, $title){
                $this->day=$day;
        $this->kickofftime=$kickofftime;
                $this->title=$title;
                return $this;
    }
}



$i=0;

$day=$html->find('h1',0);
$day->plaintext;
$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) {

$kickofftime=$matchesTR->find('td[matches]',0)->plaintext;
$kodate = date('Y-m-d H:i:s', strtotime("$matchday $kickofftime +1 hour"));
$title=$matchesTR->find('pre[class=title]',0)->plaintext;


$i++;


$title = ucwords(strtolower($title));

echo $kodate;
echo $title;


    }
        }



// clean up memory
    $html->clear();
    unset($html);

?>

I would like to echo all my variables (like country, competition, team) what I got from tomorrow.php under $kodate and $title. How can I solve this problem? I already tried a lot of variation, but I have no result. If there is some expert who can combine this I would be very happy. Thanks.


Source: json

Leave a Reply