PHP循环函数具有不同的参数

I have a function which queries an api and outputs the response as an array. I can run this function once and then I can echo the array output.

But problem for me is, I can call this function once and have output. But I'd like to loop through these function parameters and call it for multiple usernames. Example:

<?php
    require("./include/function.php");

    $Player=fetchCharacterDescriptions("Senaxx", "2");
          echo "<tr>";
            echo "<th class=\"col-md-3\">" . $Player[0]['username'] . "</th>";
            foreach ( $Player as $var ) 
                {
                echo "<th class=\"col-md-3\">",$var['class']," ",$var['light'],"</th>";
                }
            echo "</tr>";
    echo "</thead>";
    echo "</table>";
?>

And this call's the function fetchCharacterDescriptions in function.php which is:

<?php

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

$hash = array(
        '3159615086' => 'Glimmer',
        '1415355184' => 'Crucible Marks',
        '1415355173' => 'Vanguard Marks',
        '898834093'  => 'Exo',
        '3887404748' => 'Human',
        '2803282938' => 'Awoken',
        '3111576190' => 'Male',
        '2204441813' => 'Female',
        '671679327'  => 'Hunter',
        '3655393761' => 'Titan',
        '2271682572' => 'Warlock',
        '3871980777' => 'New Monarchy',
        '529303302'  => 'Cryptarch',
        '2161005788' => 'Iron Banner',
        '452808717'  => 'Queen',
        '3233510749' => 'Vanguard',
        '1357277120' => 'Crucible',
        '2778795080' => 'Dead Orbit',
        '1424722124' => 'Future War Cult',
        '2033897742' => 'Weekly Vanguard Marks',
        '2033897755' => 'Weekly Crucible Marks',
    );

function translate($x)
{
  global $hash;
  return array_key_exists($x, $hash) ? $hash[$x] : null;
}


//BungieURL
function callBungie($uri)
    {
    $apiKey = '145c4aff30864167ac4548c02c050679';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_URL, $uri);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'X-API-Key: ' . $apiKey
    ));
    if (!$result = json_decode(curl_exec($ch) , true))
        {
        $result = false;
        }

    curl_close($ch);
    return $result;
    }

//Request Player    
function fetchPlayer($username, $platform)
    {
    $result = false;
    $uri = 'http://www.bungie.net/Platform/Destiny/SearchDestinyPlayer/' . $platform . '/' . $username;
    $json = callBungie($uri);
    if (isset($json['Response'][0]['membershipId']))
        {
        $result = array(
            'membershipId' => $json['Response'][0]['membershipId'],
            'membershipType' => $platform
        );
        }
    return $result;
    }
//Request characters
function fetchCharacters($username, $platform)
    {
        $result = array();

        if($player = fetchPlayer($username, $platform)) {
            $uri = 'http://bungie.net/Platform/Destiny/'.$player['membershipType'].'/Account/'.$player['membershipId'].'?ignorecase=true';

            if( $json = callBungie($uri) ) {
                foreach ($json['Response']['data']['characters'] as $character) {
                    $result[] = $character;
                }
            }
        }
        return $result;
    }

//Request character descriptions
function fetchCharacterDescriptions($username, $platform)
    {
        $character_descriptions = array();
        if($characters = fetchCharacters($username, $platform)) {
            foreach ($characters as $character) {

                $class = translate($character['characterBase']['classHash']);
                $emblem = $character['emblemPath'];
                $backgroundpath = $character['emblemPath'];
                $level = $character['characterLevel'];
                $character_id = $character['characterBase']['characterId'];
                $light = $character['characterBase']['stats']['STAT_LIGHT']['value'];
                $username = $username;

                $character_descriptions[] = array(
                    'class'=> $class,
                    'emblem'=> $emblem,
                    'backgroundpath'=>$backgroundpath,
                    'character_id' => $character_id,
                    'characterlevel' => $level,
                    'light' => $light,
                    'username' => $username

                );
            }   

        return $character_descriptions;
        }
        return false;
    }

?>

So my function call is: fetchCharacterDescriptions("Senaxx", "2"); and i'd like to add more players to this (from an array or something) So i can request the stats for multiple usernames.

You just have to loop over the players an perform fetchCharacterDescriptions for each of them.

$players = array(
    "Senaxx" => "2",
    "SomeoneElse" => "2",
);

foreach ($players as $playerName => $platformId) {
    $Player = fetchCharacterDescriptions($playerName, $platformId);
    // do your other stuff
}

Keep in mind that your webpage will load veeery slow because every call to fetchCharacterDescriptions() executes 2 curl requests. Also - if the API is down, your site effectivly is as well (or blank at least).

You are probably better off fetching the data beforehand (in certain intervalls) and storing it into a database/csv file or something.