PEAR logo

HTML_CSS : The Definitive Guide

To Array

HTML_CSS::toArray() must be considered as a debug/help function. An easy way to explore HTML_CSS data structures.

For example, explore these definitions :

  1. html, body {
  2.   margin: 2px;
  3.   padding: 0px;
  4.   border: 0px;
  5. }
  6.  
  7. p, body {
  8.   margin: 4px;
  9. }
  10.  
  11. div#header { text-align: center; color: red; }

With script :

  1. <?php
  2. require_once 'HTML/CSS.php';
  3.  
  4. $css = new HTML_CSS();
  5.  
  6. $strcss = '
  7. html, body {
  8.  margin: 2px;
  9.  padding: 0px;
  10.  border: 0px;
  11. }
  12.  
  13. p, body {
  14.  margin: 4px;
  15. }
  16.  
  17. div#header { text-align: center; color: red; }
  18. ';
  19. $css->parseString($strcss);
  20.  
  21. $arr = $css->toArray();
  22. echo '<pre>';
  23. var_dump($arr);
  24. echo '</pre>';
  25. ?>
HTML_CSS : The Definitive Guide v 1.5.0 : January 15, 2008