1
<?
$Tweet = file_get_contents("http://api.twitter.com/1/statuses/user_timeline.json?screen_name=EdVizenor&count=1");

//$Tweet = explode(",",$Tweet);
/// If I explode and echo the $Tweet(3); i get .... "text":"mY LATEST TWEET"

var_dump(json_decode($Tweet,true));
?>

我想要做的是通过键解析出数组。就像是:

echo $Tweet(text);  /// but this does not work. 
4

1 回答 1

1

知道错误是什么会很有帮助。问题是这$Tweet(text)将调用包含在 中的函数$Tweet,因为该变量不是函数,而是实际的数组,您实际上只需要

<?php
// your code
$tweets = json_decode($Tweet,true);
echo $tweets[0]['text'];

下一次,一定要把抛出的错误包括在内,这对你阅读和理解这些很有帮助!

于 2012-10-30T02:46:04.023 回答