php make multiple api calls and merge json results

I have found topics on ways to merge JSON data but nothing specifically like what I'm trying to do. The API I'm requesting data from has an upper limit of 100 results at a time from their database. I am able to pull 100 results just fine .. I need to change the two parameters and get results in one json file...

https://api.dailymotion.com/user/test/videos?page=$page&limit=$upper

First get page 1, 100 video, then page 2, 100 and so on ..  in the end merge all results to one json file.
LVL 5
CalmSoulAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris StanyonWebDevCommented:
You would probably need to decode the JSON data in your PHP script and process it into a PHP object or array. Do this for each request, so you'll you end up with a single array or object. Then simply call json_encode() on it and echo it out.
Ray PaseurCommented:
Please see: http://iconoun.com/demo/temp_calmsoul.php
<?php // demo/temp_calmsoul.php

/**
 * See http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28632820.html
 * Ref http://php.net/manual/en/function.json-encode.php
 */
error_reporting(E_ALL);

$urls = array
( 'https://api.dailymotion.com/user/test/videos?page=1&limit=100'
, 'https://api.dailymotion.com/user/test/videos?page=2&limit=100'
)
;

$sets = array();
foreach ($urls as $url)
{
    $json = file_get_contents($url);
    $data = json_decode($json);
    $sets[] = $data;
}

$new = json_encode($sets, JSON_PRETTY_PRINT);
echo '<pre>';
echo $new;

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.