$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.
-
use array_merge Combined array no dotlong– long2018年09月14日 06:52:21 +00:00Commented Sep 14, 2018 at 6:52
-
You cant add more items to an array using string concatenation operation .=Madhur Bhaiya– Madhur Bhaiya2018年09月14日 06:52:23 +00:00Commented Sep 14, 2018 at 6:52
1 Answer 1
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);
Sign up to request clarification or add additional context in comments.
1 Comment
Midhun
Yw, Very pleasure to hear that. Please mark it as correct answer :)
lang-php