简体   繁体   中英

Array to json is displaying as “Array Array” in php

$json = array("status" => 1, "msg" => "Done");
$json .=array("mailid" => $row["mailid"], "usertype" => $row["user_type"]);


echo json_encode($json,JSON_FORCE_OBJECT); 

But i am getting "Array Array" as output.

You can't use string concatenation(.) operation for array, user array_merge instead

Please try like this

$json = array("status" => 1, "msg" => "Done");
$json_full= array_merge($json,array("mailid" => $row["mailid"], "usertype" => $row["user_type"]));

echo json_encode($json_full,JSON_FORCE_OBJECT);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM