php判断对象是否存在属性_PHP std :: Class检查属性是否存在

这篇内容涉及如何解析和处理通过TwitterSearchAPI获取的数据,特别是含有媒体属性的对象。对象中包含了hashtag、user_mention和media等信息,媒体部分详细到包括了图片的URL、大小和类型等。问题在于如何有效地检查和操作这些带有媒体属性的对象。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我使用的是Twitter Search API,它会重新排列一组对象.如果包含[‘media’]数组,我必须检查每个对象.以下是具有媒体属性的对象之一.

object(stdClass)#56 (4) {

["hashtags"]=>

array(2) {

[0]=>

object(stdClass)#57 (2) {

["text"]=>

string(9) "katyperry"

["indices"]=>

array(2) {

[0]=>

int(62)

[1]=>

int(72)

}

}

[1]=>

object(stdClass)#58 (2) {

["text"]=>

string(8) "katycats"

["indices"]=>

array(2) {

[0]=>

int(73)

[1]=>

int(82)

}

}

}

["urls"]=>

array(0) {

}

["user_mentions"]=>

array(1) {

[0]=>

object(stdClass)#59 (5) {

["screen_name"]=>

string(13) "perfkatyperry"

["name"]=>

string(7) "KatyCat"

["id"]=>

int(611836599)

["id_str"]=>

string(9) "611836599"

["indices"]=>

array(2) {

[0]=>

int(3)

[1]=>

int(17)

}

}

}

["media"]=>

array(1) {

[0]=>

object(stdClass)#60 (10) {

["id"]=>

int(325747221490434048)

["id_str"]=>

string(18) "325747221490434048"

["indices"]=>

array(2) {

[0]=>

int(83)

[1]=>

int(105)

}

["media_url"]=>

string(46) "http://pbs.twimg.com/media/BIVJXz-CAAAHQ8M.jpg"

["media_url_https"]=>

string(47) "https://pbs.twimg.com/media/BIVJXz-CAAAHQ8M.jpg"

["url"]=>

string(22) "http://t.co/RYgQ8Srze5"

["display_url"]=>

string(26) "pic.twitter.com/RYgQ8Srze5"

["expanded_url"]=>

string(66) "http://twitter.com/perfkatyperry/status/325747221486239744/photo/1"

["type"]=>

string(5) "photo"

["sizes"]=>

object(stdClass)#61 (5) {

["medium"]=>

object(stdClass)#62 (3) {

["w"]=>

int(600)

["h"]=>

int(600)

["resize"]=>

string(3) "fit"

}

["thumb"]=>

object(stdClass)#63 (3) {

["w"]=>

int(150)

["h"]=>

int(150)

["resize"]=>

string(4) "crop"

}

["large"]=>

object(stdClass)#64 (3) {

["w"]=>

int(1024)

["h"]=>

int(1024)

["resize"]=>

string(3) "fit"

}

["small"]=>

object(stdClass)#65 (3) {

["w"]=>

int(340)

["h"]=>

int(340)

["resize"]=>

string(3) "fit"

}

["orig"]=>

object(stdClass)#66 (3) {

["w"]=>

int(1024)

["h"]=>

int(1024)

["resize"]=>

string(3) "fit"

}

}

}

}

}

我怎样才能做到这一点?

谢谢!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值