php json_decode,数据由[]包装

with true option, it works fine.

sorry and thanks guys.

=============================================

I encoded php array to json with this code

$rows = array();
if ($result = $mysqli->query($query)) {
    while ($row = $result->fetch_assoc()) {
        $rows[] = $row;
    }
    echo json_encode($rows);
    /* free result set */
    $result->free();
}

end decode with

$array = json_decode($server_output)

the $server_output is like this

[{"userid":"96679","userinfor":"xxxxxxxxx","userlocation":"CA"}]
[{"userid":"153795","userinfor":"xxxxxxxxx","userlocation":"CA"}]
[{"userid":"131878","userinfor":"xxxxxxxxx","userlocation":"CA"}]

but, $array is NULL :(

Thanks in advence,

This is not valid json together:

[{"userid":"96679","userinfor":"xxxxxxxxx","userlocation":"CA"}]
[{"userid":"153795","userinfor":"xxxxxxxxx","userlocation":"CA"}]
[{"userid":"131878","userinfor":"xxxxxxxxx","userlocation":"CA"}]

While, this part is valid:

[{"userid":"96679","userinfor":"xxxxxxxxx","userlocation":"CA"}]

or any one of them separately

$json = '[{"userid":"96679","userinfor":"xxxxxxxxx","userlocation":"CA"}]';
print_r(json_decode($json, true));

Output:

Array
(
    [0] => Array
        (
            [userid] => 96679
            [userinfor] => xxxxxxxxx
            [userlocation] => CA
        )

)

The valid format for all data is like this:

[
    {
        "userid": "96679",
        "userinfor": "xxxxxxxxx",
        "userlocation": "CA"
    },
    {
        "userid": "153795",
        "userinfor": "xxxxxxxxx",
        "userlocation": "CA"
    },
    {
        "userid": "131878",
        "userinfor": "xxxxxxxxx",
        "userlocation": "CA"
    }
]