V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
ifwangs
V2EX  ›  PHP

小白求问这类复杂对象的数组如何取某个值

  •  
  •   ifwangs · 2020-03-27 19:13:06 +08:00 · 2151 次点击
    这是一个创建于 1491 天前的主题,其中的信息可能已经有所发展或是发生改变。
    LeanCloud\LeanObject Object
    (
    [_className:LeanCloud\LeanObject:private] => Comment
    [_data:LeanCloud\LeanObject:private] => Array
    (
    [objectId] => byz6
    [nick] => kiss
    [updatedAt] => DateTime Object
    (
    [date] => 2020-03-27 17:53:46.268000
    [timezone_type] => 3
    [timezone] => PRC
    )

    [mail] => gu*****[email protected]
    [ua] => Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3650.400 QQBrowser/10.4.3341.400
    [insertedAt] => DateTime Object
    (
    [date] => 2019-04-06 16:52:21.524000
    [timezone_type] => 3
    [timezone] => PRC
    )

    [emailHash] => 5087d65a917e9373cf77a87497d018ae
    [createdAt] => DateTime Object
    (
    [date] => 2019-04-06 16:52:21.524000
    [timezone_type] => 3
    [timezone] => PRC
    )

    [link] => http://www.*****.vip
    [comment] =>
    kiss 友链



    [url] => /links.html
    [isNotified] => 1
    )

    [_operationSet:LeanCloud\LeanObject:private] => Array
    (
    )

    [_saveOption:LeanCloud\LeanObject:private] =>
    )



    比如我要取 objectId 应该怎么写
    3 条回复    2020-03-27 22:27:02 +08:00
    xiaoming1992
        1
    xiaoming1992  
       2020-03-27 19:22:48 +08:00 via Android
    没有格式的,没人能看懂
    littleylv
        2
    littleylv  
       2020-03-27 19:47:56 +08:00
    看源码哟
    https://github.com/leancloud/php-sdk/blob/master/src/LeanCloud/LeanObject.php#L221
    $a->getObjectId()
    或者 $a->get('objectId')
    其他字段没有暴露 getX 方法,可以通过 $a->get('mail') https://github.com/leancloud/php-sdk/blob/master/src/LeanCloud/LeanObject.php#L304
    ifwangs
        3
    ifwangs  
    OP
       2020-03-27 22:27:02 +08:00
    @littleylv 感谢,一遍遍的看文档,看到怎么处理了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2806 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 126ms · UTC 12:24 · PVG 20:24 · LAX 05:24 · JFK 08:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.