How to structure a foreach / implode in multi array

1

I'm having a problem listing an array inside a table, I'm using a function to capture information from a .torrent file and display it in a table, however when the files are inside a folder, the list keeps repeating the folder name.

Howcouldyougetaroundthisproblem.

<table><thead><tr><thscope='col'>ARQUIVOS</th><thscope='col'>TAMANHO</th></tr></thead><tbody><?phpforeach($torrent->result['info']['files']as$file){echo"
                <tr>
                    <td class='announce-list-file'>" . implode('<tr><td>',$file['path']) . "</td>
                    <td class='announce-list-file'>" . formatSizeUnits($file['length']) . "</td>
                </tr>";
            }
        ?>
    </tbody>
</table>
    
asked by anonymous 27.12.2018 / 01:06

1 answer

0

A suggestion would be to get only the last value of the $file['path'] array using the end() function that will always return the file name, so it will not have folders and subfolders in the table.

<table>
<thead>
    <tr>
        <th scope='col'>ARQUIVOS</th>
        <th scope='col'>TAMANHO</th>
    </tr>
</thead>
<tbody>
    <?php foreach($torrent->result['info']['files'] as $file) {      
        echo "
           <tr>
            <td class='announce-list-file'>".end($file['path']) ."</td>
            <td class='announce-list-file'>".$file['length']."</td>
        </tr>";
    }
    ?>
</tbody>

    
28.12.2018 / 01:28