imagestring中的数组值

时间:2012-12-05 19:25:10

标签: php

<?php
header ('Content-Type: image/png');
$img = imagecreatefrompng('http://i.imgur.com/uBaMn.png');
$color = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);
imagestring($img, 1, 20, 21, $f['5'], $color);
imagepng($img);
imagedestroy($img);
?>
<?php 
$url = "http://2006scape.com/services/hiscores/index_lite.ws?player1=boardwalk";
    $f = explode(",", file_get_contents($url));
    print_r($f);
?>

请注意:$ f ['5']

我正在尝试回应数组5,但它不起作用,因为它需要使用双引号或单引号,但如果我这样做,它会完全回应:“$ f ['5'] ”

1 个答案:

答案 0 :(得分:0)

只需更改代码的位置

即可
$url = "http://2006scape.com/services/hiscores/index_lite.ws?player1=boardwalk";
$f = explode(",", file_get_contents($url));


header ('Content-Type: image/png');
$img = imagecreatefrompng('http://i.imgur.com/uBaMn.png');
$color = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);
imagestring($img, 5, 220, 6, "F5 : " . $f['5'], $color);
imagepng($img);
imagedestroy($img);

输出

enter image description here