Foreach in PHP with Simplexmlelement Object

Asked

Viewed 107 times

0

I need to have access to the information (id_midia, midia_tipo, etc.) within the object array below. How should I proceed?

 [midias] => SimpleXMLElement Object
                                    (
                                        [midia] => SimpleXMLElement Object
                                            (
                                                [0] => SimpleXMLElement Object
                                                    (
                                                        [id_midia] => abcdef
                                                        [ds_midia_credi] => gggggg
                                                        [ds_midia] => aaaaaaaa
                                                        [nm_midia_inter] => imagem_01.jpg
                                                        [midia_link] => http://portal.teste///_midias/jpg/2018/02/07/imagem_01.jpg
                                                        [midia_tipo] => 2
                                                    )

                                                [1] => SimpleXMLElement Object
                                                    (
                                                        [id_midia] => abcdef
                                                        [ds_midia_credi] => gggggg
                                                        [ds_midia] => aaaaaaaa
                                                        [nm_midia_inter] => video_01.jpg
                                                        [midia_link] => http://portal.teste///_midias/jpg/2018/03/07/video_01.mpg
                                                        [midia_tipo] => 4
                                                    )
  • The/xml code you have to generate this structure is useful too, edits put pff

  • To generate this structure I give a print_r($results);

  • 1

    @Diegoalbuquerque Miguel meant the code that generates the content of $resultado.

  • 1

    foreach($media->media as $key => $data){ echo $data->id_midia}

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.