oh srry i forgot to include this part, the array's exists and is created through PHP
$counters;
$mysqli = new mysqli($host, $sqluser, $sqlpass, "counters");
foreach (glob("img/champions/*.jpg") as $filename)
{
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$path = $filename;
$file = basename($path);
$file = basename($path, ".jpg");
$search = "SELECT * FROM counters WHERE `IMG_Name`='".$file."'";
if ($searchresult = mysqli_query($mysqli, $search)) {
/* fetch associative array */
while ($row = mysqli_fetch_assoc($searchresult)) {
${$file}["1"] = $row["Counter 1"];
${$file}["2"] = $row["Counter 2"];
${$file}["3"] = $row["Counter 3"];
${$file}["4"] = $row["Counter 4"];
${$file}["5"] = $row["Counter 5"];
${$file}["6"] = $row["Counter 1"];
${$file}["7"] = $row["Counter 2"];
${$file}["8"] = $row["Counter 3"];
${$file}["9"] = $row["Counter 4"];
${$file}["10"] = $row["Counter 5"];
${$file}["11"] = $row["Good With 1"];
${$file}["12"] = $row["Good With 2"];
${$file}["13"] = $row["Good With 3"];
${$file}["14"] = $row["Good With 4"];
${$file}["15"] = $row["Good With 5"];
}
}
echo $file." = ".json_encode(${$file})." ,";
}
?>
And an example of an array that gets created:
var ahri = {"1":"ryze","2":"fizz","3":"Akali","4":"LeBlanc","5":"Diana","6":"ryze","7":"fizz","8":"Akali","9":"LeBlanc","10":"Diana","11":"Jax","12":"Irelia","13":"Shen","14":"Ezreal","15":"Amumu"}