quote:
Originally posted by Guillaume
I dont know if I understood fully, but I tried code:
<?
....
header("Content-type: image/png");
$im = @imagecreate(100, 200)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 1, 5, 5, $match[1] , $text_color);
imagepng($im);
imagedestroy($im);
?>
and got
PS: that was to see if i could make it work.
the array highlighted is an array inside an array so you need to reference it like
code:
$match[1][X]
(where x is a number from 0 to 3 well if theres more you just keep counting up )
so
code:
echo $match[1][0];
would produce your first stat .
then to get your 2nd stat you would do
code:
echo $match[1][1];
so to produce your image i would do something like
code:
<?
$handle = fopen("http://www.bungie.net/Stats/PlayerStats.aspx?player=guyguyme2003", "rb");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
$match = InsideTags('<div class="ExpBar" style="width:50"><div class="ExpBarText" style="left:20">','</div></div>',$contents); // uses a regular expression and gets the stuff inbetween those two points and returns it
foreach ($match[1] as $stat){ //just echo's all your stats
echo "$stat <br>";
}
$text = array("Stats for map X = $match[1][0]","Stats for map X = $match[1][1]","Stats for map X = $match[1][2]","Stats for map X = $match[1][3]","Stats for map X = $match[1][3]");
header("Content-type: image/png");
$im = @imagecreate(100, 200)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 0, 0, 0);
$line = 5;
foreach ($text as $string){
imagestring($im, 1, 5, $line, $string , $text_color);
$line = $line +10; //makes sure text dosnt overlap so each thing in array $text is on a new line adjust this as you need
}
imagepng($im);
imagedestroy($im);
function InsideTags($tag1,$tag2,$html){ //function to grab text inbetween two points
$tag2 = str_replace('/', "\/" ,$tag2);
preg_match_all("/$tag1(.*)$tag2/i", $html, $match);
return $match;
}
?>
That should work I hope but im not home to test it ill test it later
edit :
blahhhhhhhhhhhhh wdz beat me