Well, to remove that code that echoes your stats (useless if you want an image output) and also rename the variables so they're easier to understand, delete this code...
code:
foreach ($match[1] as $stat){ //just echo's all your stats
echo "$stat <br>";
}
And replace it with this...
code:
$rumble_pit = $match[1][0];
$team_skirmish = $match[1][1];
$head_to_head = $match[1][2];
$big_team_battle = $match[1][3];
$team_slayer = $match[1][4];
Now you can use those simple variables in the imagestring() function. The current code is trying to write "$match[1]" on the image, but that's actually an array, so it won't work.