Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get value from array XML

I want to develop chat with facebook by jaxl.v3. This is my code

    `$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); 
      });`

This is my result that I print print_r($stanza) :

image of my PrtScn

What's I ask now:

  • if I want to get [text]=>hi value. how should I write? I am try my best a long time ago but I am still can't get value Hi from this array . pleases help me to solve it. Thanks I am looking to see your reply soon.
like image 712
sk juli kaka Avatar asked Jan 29 '26 20:01

sk juli kaka


1 Answers

Try this:

foreach($stanza->childrens as $child) {
   echo $child->text, '<br>';
}
like image 97
silkfire Avatar answered Feb 01 '26 10:02

silkfire



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!