【发布时间】:2013-09-20 20:24:28
【问题描述】:
这可能很简单,但我束手无策。
我正在使用 API。我声明了 $checkLead 并获得了一个 stdClassObject ,它将显示在下面。我正在尝试检索数组的值。在这种情况下,只有一条记录,但将来可能会包含更多。
这是我 print_r 时打印的内容。
stdClass Object (
[result] => stdClass Object (
[count] => 1
[leadRecordList] => stdClass Object (
[leadRecord] => stdClass Object (
[Id] => 26
[Email] => test3@test.com
[ForeignSysPersonId] =>
[ForeignSysType] =>
[leadAttributeList] => stdClass Object (
[attribute] => Array (
[0] => stdClass Object (
[attrName] => FirstName
[attrType] => string
[attrValue] => JJ
)
[1] => stdClass Object (
[attrName] => LastName
[attrType] => string
[attrValue] => JJ
)
[2] => stdClass Object (
[attrName] => Website
[attrType] => url
[attrValue] => test.com
)
)
)
)
)
)
)
这里是一个多结果返回的例子。
stdClass Object (
[result] => stdClass Object (
[count] => 2
[leadRecordList] => stdClass Object (
[leadRecord] => Array (
[0] => stdClass Object (
[Id] => 33
[Email] => test3@test.com
[ForeignSysPersonId] =>
[ForeignSysType] =>
[leadAttributeList] => stdClass Object (
[attribute] => Array (
[0] => stdClass Object (
[attrName] => FirstName
[attrType] => string
[attrValue] => jj )
[1] => stdClass Object (
[attrName] => LastName
[attrType] => string
[attrValue] => amonit )
[2] => stdClass Object (
[attrName] => Website
[attrType] => url
[attrValue] => test.com )
)
)
)
[1] => stdClass Object (
[Id] => 26
[Email] => test3@test.com
[ForeignSysPersonId] =>
[ForeignSysType] =>
[leadAttributeList] => stdClass Object (
[attribute] => Array (
[0] => stdClass Object (
[attrName] => FirstName
[attrType] => string
[attrValue] => bob )
[1] => stdClass Object (
[attrName] => LastName
[attrType] => string
[attrValue] => smith )
[2] => stdClass Object (
[attrName] => Phone
[attrType] => phone
[attrValue] => 123-123-1234 )
[3] => stdClass Object (
[attrName] => Website
[attrType] => url
[attrValue] => test.com )
)
)
)
)
)
)
)
所以,我想知道是否有人可以帮助我检索 FirstName 的值。我还希望能够通过说“LastName 的值是多少,其中FirstName 等于"JJ"。
【问题讨论】:
-
对于
what is the value of LastName where the FirstName is equal to "JJ",您需要提供另一个示例,说明何时找到了多条记录。看起来在此搜索中您只得到一个结果。如果找到多个结果,则必须使用 foreach 才能找到正确的结果数组。 -
好的@Pitchinnate,我有一个多结果返回的例子。我已将其添加到 OP。在此先感谢您的帮助。我应该在星期一之前解决这个问题。
-
@Pitchinnate,关于您的上述回复。我想知道如何从这些场景中的任何一个中检索值。请帮我。我在这个网站和其他网站上找到的解决方案似乎不起作用。