3

I have a php script that has three queries that are each returning a set of results.
Now i want to combine the results from the three queries into a single JSON array.

Anyone knows how to achieve this?
The queries can't be joined.

Thanks.

1
  • What are you using to retrieve the data? mysql_*, mysqli_*, PDO... Commented Jan 14, 2014 at 13:50

1 Answer 1

6

You might want to look into array_merge().

A simple example:

<?php
$result = array_merge($array_result_of_query1, $array_result_of_query2, $array_result_of_query3);
echo json_encode($result);
?>
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.