Traversing an object array in php using the foreach

0

I'm having trouble displaying the information in a simple table in html, I'm trying everything, the php code is this:

<?php
$header = true;
echo '<html><body><table><meta http-equiv="Content-Type" 
content="text/html"; 
charset="iso-8859-1">';
if ($header){
  foreach ($obg->conteudo->coluna as $col => $valor){
         echo'<th>'.htmlentities( $valor ).'</th>';
  }
   $header=false;
}
echo '</table></body></html>';
?>

The variable $obg = simplexml_load_string(uma variavel com xml string); , that is, it is an object.

The error is as follows:

  

PHP Notice: Trying to get property of non-object

    
asked by anonymous 04.04.2018 / 16:29

0 answers