<?php
class Matrix {
    public function 
__parse(){
        
$parsed = new SimpleXMLElement(file_get_contents('site.xml'));
        
$return '';
        foreach(
$parsed->row as $row){
            
$text = (strlen($row) > $this->__text($row,$row['offset']) : $this->__row());
            if(
$row['border'] == "top")
                
$text '<b id=h>'.$text.'</b>';
            elseif(
$row['border'] == "bottom")
                
$text '<b id=i>'.$text.'</b>';
            
$return .= $text."\n";
        }
        return 
$return;
    }

    public function 
__row($length=75,$rows=1){
        
$return '';
        
$letters range('a','g');
        for(
$row 0$row $rows$row++){
            for(
$line 0$line $length$line++)
                
$return .= '<b id='.$letters[mt_rand(0,6)].'>'.mt_rand(0,1).'</b>';
            if(
$rows 1)
                
$return .= "\n";
        }
        return 
$return;
    }

    public function 
__text($text,$offset=0){
        
$eq = (75 strlen(html_entity_decode(strip_tags($text)))) / 2;
        
$left $eq $offset;
        
$right $eq $offset;
        if(
is_float($left))
            
$right--;
        return 
$this->__row($left).$text.$this->__row($right);
    }
}
?>