【发布时间】:2015-05-20 13:37:19
【问题描述】:
我只想输出一次followers_count 的值。我使用foreach 循环设法做到了这一点,但这显然会多次输出结果。还有其他一些简单的方法可以做到这一点吗?
数组声明如下:
$tweetsshow = $connection->get("https://api.twitter.com/1.1/users/show.json?screen_name=".$twitteruser);
echo $tweetsshow[0]->user->followers_count;
array(30) {
[0]=>
object(stdClass)#5 (24) {
["created_at"]=>
string(30) "Wed May 20 12:32:30 +0000 2015"
["id"]=>
float(6.010025574446E+17)
["id_str"]=>
string(18) "601002557444595712"
["text"]=>
string(79) "Judge Farrugia Sacco loses appeal http://t.co/njcgvTDTej http://t.co/GRjnBt13uC"
["source"]=>
string(71) "Times of Malta"
["truncated"]=>
bool(false)
["in_reply_to_status_id"]=>
NULL
["in_reply_to_status_id_str"]=>
NULL
["in_reply_to_user_id"]=>
NULL
["in_reply_to_user_id_str"]=>
NULL
["in_reply_to_screen_name"]=>
NULL
["user"]=>
object(stdClass)#6 (39) {
["id"]=>
int(390687940)
["id_str"]=>
string(9) "390687940"
["name"]=>
string(14) "Times of Malta"
["screen_name"]=>
string(15) "TheTimesofMalta"
["location"]=>
string(5) "Malta"
["description"]=>
string(74) "General, sporting, and business news for Malta and the surrounding region."
["url"]=>
string(22) "http://t.co/OYjxN0Y4tX"
["description"]=>
object(stdClass)#10 (1) {
["urls"]=>
array(0) {
}
}
}
["protected"]=>
bool(false)
["followers_count"]=>
int(13865)
["friends_count"]=>
int(13)
["listed_count"]=>
int(153)
["created_at"]=>
string(30) "Fri Oct 14 11:20:15 +0000 2011"
["favourites_count"]=>
int(0)
【问题讨论】: