Reputation: 86
I am trying to send a single PHP variable to a client via json. However, if I generate the string myself and pass it into json_encode, it adds / around the key. I am using:
$threadID = mysqli_insert_id($Thesisdb);
$threadtoJ='{"id":'.$threadID.'}';
echo json_encode($threadtoJ);
I am looking for an output like this: {"id","12"}
Upvotes: 2
Views: 361
Reputation: 86
echo json_encode(array("id" => 12));
Is the correct answer. Thanks @u_mulder
Upvotes: 3