Q:

JSON/PHP - RIOT API - How to retrieve datasets

I am working on a big data project for university. I am using RIOT's API for league of legends. I want to collect all playernames with their division,tier,LP,wins from their api. Possibly 2500-10000 players per region. I failed to find a solution to this because its dumb to single query this every time.
How could this possibly be fixed? This is the code that will get all players from my own division in EUW. Maybe forloop?
<?php
    header('Content-Type: text/html; charset=utf-8');

    ini_set("display_errors", "1"); error_reporting(E_ALL);

    $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, 'https://euw.api.pvp.net/api/lol/euw/v2.5/league/by-summoner/31827832?api_key=key');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        $response = curl_exec($ch);

        curl_close($ch);

    $json = json_decode($response, true);

    $json = array_pop($json);
    foreach($json[0]['entries'] as $entry){
        // print_r($json);
                echo $entry['playerOrTeamName'] . ',' . $json[0]['tier'] . ',' . $entry['division'] . ',' . $entry['leaguePoints'] . ',' . $entry['wins'] . "<br/>";
            }
?>

The problem is, that this data can not be mixed with other data. I have to retrieve division by division and not all at the same time. Could the values be comma seperated by using fput_csv(); ?
I am unexperienced (have not done this type of job before) in this, any help is greatly appreciated. If you need additional information on this, please ask so. I hope we can work this out. I'm lost.
PS: the current code shown above is live at http://20ff.net

A:

From my understanding, you don't know what to do with the data once you've fetched it, and you want to fetch it again later without having to call the API each time.
What you need is called "persistent storage", so you can store your data somewhere and be able to retrieve it easily and in a reasonable amount of time. There are many ways you could do that, a CSV file is one, as you've mentioned. 
For this project, I recommend you use a real database (with PHP most people use MySQL), obviously we can't teach you that entire concept on SO, but you can read about it here.

