0

There is a json string and it's

["email",{},"text","[email protected]"]

I don't how to generate the '{}' by json_encode($data, JSON_UNESCAPED_SLASHES); I try several sample codes like:

$data = ["email", null, "text", "[email protected]"];  // the output is ["email",null,"text","[email protected]"]
$data = ["email", "", "text", "[email protected]"]; // the output is ["email","","text","[email protected]"]
$data = ["email", [], "text", "[email protected]"]; // the output is ["email",[],"text","[email protected]"]

Does anyone know how to do? Thank you. Regards.

1 Answer 1

1
$data = ["email", new stdclass, "text", "[email protected]"];

echo json_encode($data);

will output

["email",{},"text","[email protected]"]
Sign up to request clarification or add additional context in comments.

Comments

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.