0
$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.

2
  • use array_merge Combined array no dot Commented Sep 14, 2018 at 6:52
  • You cant add more items to an array using string concatenation operation .= Commented Sep 14, 2018 at 6:52

1 Answer 1

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

Yw, Very pleasure to hear that. Please mark it as correct answer :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.