-2
<?
$jsonString = '{"meta":{"status":200,"msg":"OK"},"response":{"blog":


{"title":"happiness.","posts":12215,"name":"random","url":"http:\/\/www.demo.com\/","updated":1354380368,"description":"","ask":true,"ask_anon":true,"share_likes":true,"likes":166 1}}}';
    $jsonObject = json_decode($jsonString);
    $result = '';
    foreach ($jsonObject->response as $blog) {
    $result .= $blog->title . ' - ' . $blog->url . '<br/>' . "\n";
    }
    echo $result;
    ?>

从 $blog->url 开始。返回一个 url,我怎样才能把这个 url 放在一个锚标签中?

4

1 回答 1

1

用锚标记包装它,调用urlencode()以确保正确编码 URL 字符:

$result .= $blog->title . ' - <a href="' . urlencode( $blog->url) . '">' . $blog->title . '</a><br/>' . "\n";
于 2012-12-12T16:01:55.903 回答