Class and Array Help Needed

I am new to PHP and am having a very hard time trying to use a class I've downloaded.

 It seems like a simple class that breaks down information into arrays. However, I have no idea on how to access the arrays the class produces. I can use the var_dump function and see the arrays but after many many many hours of trying I can't access them at all. I have no idea of how to access any of the info the class produces.

Here is the class

============== Class Code =====================================================

class TorrentFile {
    var $index;
    var $source;
    var $final_array;

    function handler() {
        $char = $this->source[$this->index];

        if (is_numeric($char)) return $this->handler_string();
        if ($char == 'i') {
            return $this->handler_int();
        if ($char=='l') {
            return $this->handler_list();
        if ($char=='d') {
            return $this->handler_dictonary();

        die("MAIN HANDLER: UNEXPECTED CHAR (position: $this->index): ".$char);

    function handler_int() {
        $number = "";

        while (($current_char = $this->source[$this->index]) != 'e') {
            $number .= $current_char;


        return (int) $number;

    function handler_string(){
        $size ="";
        while($this->source[$this->index] != ':') {
            $size .= $this->source[$this->index];

        $i = ++$this->index;
        $this->index += $size;

        $x= substr($this->source, $i, $size);

        return $x;

    function handler_list() {
        $return_list = array();

        while ($this->source[$this->index] != 'e') {
            $this->index1 = $this->index;
            $return_list[] = $this->handler();
            if ($this->index1 == $this->index) die("INFINITE LOOP IN THE LIST");

        return $return_list;

    function handler_dictonary() {
        $return_dict = array();

        while ($this->source[$this->index] != 'e') {
            $this->index1 = $this->index;
            $return_dict[$this->handler_string()] = $this->handler();
            if ($this->index1 == $this->index) die("INFINITE LOOP IN THE DICTONARY");

        return $return_dict;

    function parse_file($filename) {
        $this->source = $filename;

        $this->index = 0;
        $filesize = strlen($this->source);


        while($this->index<$filesize) {
            $this->index1 = $this->index;
            $this->final_array[] =$this->handler();
            if ($this->index1 == $this->index) die("INFINITE LOOP IN THE ROOT LIST");

        $this->source = '';
        return $this->final_array;

====================== End of Class ===========================================

I can pass a file to the class to break down the info into great data, but how in the world do you access the info so you can actually use it???

 I can't find any help files on the net that can simply explain this for me.

Please Help
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

would be nice to post some outcome and how u call it, but for now, try this
$x = new TorrentFile();
$z = array();
$z = $x->parse_file($someFile);
echo $z[0];

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.