File: example_3_parent_and_child_nodes

Recommend this page to a friend!
  Classes of Tony Frezza  >  HTML Generate  >  example_3_parent_and_child_nodes  >  Download  
File: example_3_parent_and_child_nodes
Role: Example script
Content type: text/plain
Description: Example 3 Parent And Child Nodes
Class: HTML Generate
Generate HTML from arrays
Author: By
Last change: edit class name to UML template
Date: 4 years ago
Size: 1,880 bytes
 

Contents

Class file image Download
<?php

/**
 * @author Tony Frezza
 * @copyright 2017
 */

   
include('html.php');
   
   
   
$html = new Html;
   
   
   
/**
        En:
            Note that each node relative to a tag is informed by an array.
            Each child node is an array, since it is a tag.
            So, for the children of a parent node, we will have an array of arrays
       
        Pt-BR:
            Observe que cada n relativo a uma tag informado por um array.
            Cada n filho uma array, uma vez que uma tag.
            Assim, para os ns filhos de um n pai, teremos um array de arrays
     */
    
    
   
$html->add(
        array(
           
'tag' => 'ul',
           
'children' => array(
                array(
                   
'tag' => 'li',
                   
'text' => 'foo'
               
),
                array(
                   
'tag' => 'li',
                   
'text' => 'bar'
               
)
            )
        )
    );
   
    echo
$html->getHtml();
   
   
$html->resetHtml();
   
   
$html->add(
        array(
           
'tag' => 'div',
           
'style' => 'width: 100%; border: solid; text-align: center;',
           
'children' => array(
                array(
                   
'tag' => 'div',
                   
'style' => 'width:100%; height: 20px; background: red;',
                   
'text' => 'Child DIV node with style attribute',
                ),
                array(
                   
'tag' => 'div',
                   
'style' => 'width:100%; height: 30px; background: blue;',
                   
'text' => 'Child DIV node with style attribute',
                ),
            )
        )
    );
   
    echo
$html->getHtml();

?>

For more information send a message to info at phpclasses dot org.