home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / HTML / Table / Matrix / Filler / Random.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  2.6 KB  |  73 lines

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2002 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 3.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/3_0.txt.                                  |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Ian Eure <ieure@php.net>                                    |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Random.php,v 1.1.1.1 2004/04/19 23:47:14 ieure Exp $
  20.  
  21. /**
  22.  * Fill randomly
  23.  *
  24.  * @author Ian Eure <ieure@php.net>
  25.  * @package HTML_Table_Matrix
  26.  * @since 1.0
  27.  */
  28. class HTML_Table_Matrix_Filler_Random extends HTML_Table_Matrix_Filler {
  29.     var $map = array();
  30.  
  31.     /**
  32.      * Constructor
  33.      *
  34.      * @param Object $matrix Reference to the HTML_Table_Matrix instance we are
  35.      *                       filling data for.
  36.      * @param array $options Options for this Filler
  37.      * @return void
  38.      */
  39.     function HTML_Table_Matrix_Filler_Random(&$matrix, $options = false) {
  40.         $this->setOptions($options);
  41.         $this->matrix = &$matrix;
  42.         srand(microtime());
  43.     }
  44.     
  45.     function _initMap()
  46.     {
  47.         $this->matrix->_calculateSize();
  48.         for ($row = 0; $row < $this->matrix->_rows; $row++) {
  49.             for ($col = 0; $col < $this->matrix->_cols; $col++) {
  50.                 $this->map[$row][$col] = 1;
  51.             }
  52.         }
  53.     }
  54.  
  55.     /**
  56.      * Get the next cell.
  57.      *
  58.      * @param int $index Where we're at in the data-set
  59.      * @return array 1-dimensional array in the form of (row, col) containing the
  60.      *               coordinates to put the data for this loop iteration
  61.      */
  62.     function next($index) {
  63.         
  64.         $this->_initMap();
  65.         print "rows: ".$this->matrix->_rows."<br/>\n";
  66.         print "cols: ".$this->matrix->_cols."<br/>\n";
  67.         print "unf: ".count($this->map[0]);
  68.  
  69.  
  70.         return array($this->row, $this->col);
  71.     }
  72. }
  73. ?>