我有一个solr查询输出“突出显示”在一个对象我不知道如何访问它的数据。让我们说我想回到“Black& Red”我试过了:
$object->{10304}->color_source_name[0];
$object->{'10304'}->color_source_name[0];
两者都没有给我任何东西。如何访问数据?
这是我在下面引用的对象:
print_r($object);
SolrObject Object
(
[10304] => SolrObject Object
(
[color_source_name] => Array
(
[0] => Black & Red
)
[description] => Array
(
[0] => with their true identity safely masked.Midcalf Lucha Red
)
[name] => Array
(
[0] => Sock It To Me Lucha Red Midcalf
)
[color] => Array
(
[0] => Red
)
)
[4075] => SolrObject Object
(
[color_source_name] => Array
(
[0] => Beige/Red
)
[description] => Array
(
[0] => Very sheer with red tops and Cuban heels and an oh-so-sexy red backseam. These are designed
)
[name] => Array
(
[0] => Two-Tone Red Cuban-Heeled Stockings
)
[color] => Array
(
[0] => Red
)
)
)
答案 0 :(得分:3)
根据http://php.net/manual/en/class.solrobject.php SolrObject
实施ArrayAccess
,您可以使用方括号,例如。
echo $object[4075]['colour_source_name'][0];