-2
<?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']”。

4

1 回答 1

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);

输出

在此处输入图像描述

于 2012-12-05T19:36:08.827 回答