How to output this json {},{} with php?
Get the solution ↓↓↓I was unable to output this:
[{"title":"London","foo":"bar"},{"title":"Istanbul","foo":"bar"}]
I cannot make comma here:},{
I can output this[{"title":"London","foo":"bar"}]
but not the first example.
Answer
Solution:
This will produce the desired output:
$data = array(
array("title" => "London",
"foo" => "bar"
),
array("title" => "Istanbul",
"foo" => "bar"
)
);
echo json_encode($data);
Make sure you create your arrays correctly. For more information have a look at the documentation for .
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: port 80 in use by "unable to open process" with pid 4!
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.