<?php
require_once 'ReaderInterface.php';

class 
CsvFileReader implements ReaderInterface
{
    private 
$_filename;
    private 
$_handler;

    public function 
__construct($filename)
    {
        if (!
is_readable($filename)) {
            throw new 
RuntimeException('File [' $filename '] is not readable.');
        }
        
$this->_filename $filename;
    }

    public function 
read()
    {
        
$this->_handler fopen($this->_filename'r');
    }

    public function 
display()
    {
        
$column 0;
        
$tmp    '';

        while (
$data fgetcsv($this->_handler1024',')) {
            
$num count($data);
            for (
$i 0$i $num$i++) {
                if (
$i == 0) {
                    if (
$column != && $data[$i] != $tmp) {
                        echo 
'</ul>';
                    }
                    if (
$data[$i] != $tmp) {
                        echo 
'<b>' $data[$i] . '</b>';
                        echo 
'<ul>';
                    }
                } else {
                    echo 
'<li>' $data[$i] . '</li>';
                }
            }
            
$column++;
        }
        echo 
'</ul>';

        
fclose($this->_handler);
    }
}