Encoding json which contains arrays

时间:2015-05-18 17:27:25

标签: php arrays json

I'm currently putting a Json file together in PHP as below

function createJson($eventIds, $TipsTB, $TipsTW) {

    $jsonData = new stdClass();

    $jsonData->source = "Betting Tips";
    $jsonData->published = date('Y-m-d H:s:i;');
    $jsonData->status = true;
    $jsonData->eventIDs = $eventIds;
    $jsonData->TipsTB = $TipsTB;
    $jsonData->TipsTW = $TipsTW;

    return $jsonData;
}

$eventIDs, $TipsTB and $TipsTW are all arrays. The first containing number strings the second two containing text strings.

When I return from the function and use

echo json_encode($jsonData);

I get

{"source":"Betting Tips","published":"2015-05-18 18:54:22;","status":true,"eventIDs":[],"TipsTB":[]}

and not a list of what is inside the brackets of the array. Has the data in the array been appended or is there a different function do do that.?

Thanks muchas...

0 个答案:

没有答案