Chickenturtle
Chickenturtle

Reputation: 151

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.

Upvotes: 0

Views: 46

Answers (1)

Midhun
Midhun

Reputation: 1167

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);

Upvotes: 1

Related Questions