Skip to content Skip to sidebar Skip to footer

How To Create A Filetree Like Table From An Object?

I was a little bit confused when I made my first post. This time I'll be more specific. I'm trying to make a 'filetree-like' table from an object (From a php-transmission project).

Solution 1:

I found the answer of the first part of my problem. Here's my code (based on my old post):

functioncreateArray ($filesObject)
  {
  $result = array();
  foreach($filesObjectAS$file) 
    {
    $prev = &$result;
    $s = strtok($file->getName(), '/');

     while (($next = strtok('/')) !== false) 
        {
        if (!isset($prev[$s])) {
        $prev[$s] = array();
        }

        $prev = &$prev[$s];
        $s = $next;
        }

    $prev[] = $s.'|'.$file->getSize().'|'.$file->isDone(); // Delimiter is '|'unset($prev);
    }
  return$result;
  }

The second part consists in displaying this array in some kind of file tree style html table. If someone have anny ideas?

Post a Comment for "How To Create A Filetree Like Table From An Object?"