【问题标题】:How to get value from array XML如何从数组 XML 中获取值
【发布时间】:2013-04-04 19:58:17
【问题描述】:

我想通过 jaxl.v3 开发与 facebook 的聊天。 这是我的代码

    `$client->add_cb('on_chat_message', function($stanza) {

                 global $client;
                 // echo back incoming message stanza 
                 $stanza->to = $stanza->from;
                 $stanza->from = $client->full_jid->to_string();
                 print_r($stanza);
                 sendMessage($client); 
      });`

这是我打印print_r($stanza) 的结果:

我现在要问什么:

  • 如果我想获得[text]=>hi 值。我该怎么写?我很久以前就尽力了,但我仍然无法从这个数组中获得价值Hi。请帮我解决它。谢谢 我希望尽快看到您的回复。

【问题讨论】:

    标签: php xml arrays facebook-graph-api xmpp


    【解决方案1】:

    试试这个:

    foreach($stanza->childrens as $child) {
       echo $child->text, '<br>';
    }
    

    【讨论】:

    • 非常感谢@silkfire。是工作。你很聪明,只要看几次就可以做对了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-24
    • 2023-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-27
    相关资源
    最近更新 更多