List folder and subfolders in a PHP foreach

0

This is using a simple function to capture information from a .torrent file and add it to an array, then list it on a table using foreach, only the directories do not appear as they should, the path to the file only appears, and it repeats the name of the folders.

As it appears:

Asyoucansee,makingthefilesfollowthedirectoryofthefolder,apracticalexample,justsearchwiththetermfoldertreestructuretogetasimpleidea:

Viewthefirstfolderandlistthefilesinside,andsoon.

<table><thead><tr><thscope='col'>ARQUIVOS</th><thscope='col'>TAMANHO</th></tr></thead><tbody><?phpif(isset($torrent->result['info']['files'])){foreach($torrent->result['info']['files']as$file){echo"<tr><td>
    <a>".extension(implode('\',$file['path']))."</a>".implode('\',$file['path'])."</td>
    <td>".$file['length'])."</td></tr>";
    } ?>
    <?php } else { 
    echo "<tr><td>".$torrent->result['info']['name']."</td>
    <td>".$torrent->result['info']['length']."</td></tr>";
    } ?>
</tbody>
</table>
  • I removed the class to shorten the code.

  • I'll leave the project source in the github for anyone who takes a closer look.

asked by anonymous 25.12.2018 / 17:42

0 answers