1

I want my array to be two dimensional. My code is :

$tabelka=glob('music/*');
$tabelkaa=natsort($tabelka);


foreach ($tabelka as $filename) {


     $list .= '<td>' . filesize($filename) . '</td><td>' . date ("F d Y H:i:s.", filemtime($filename)) . '</td>'.PHP_EOL;


     }

    echo ($list);

This code is on external device (rapsberry pi) and is used on server with 'file()' command. To achieve what i want a two dimensional array is needed. One dimension of this array needs to be filesize and the second would be filemtime.

3
  • Make an array instead of adding it to a list variable Commented Feb 13, 2014 at 14:45
  • To be honest with you, i have no idea how to put it into an array, i always used variables Commented Feb 13, 2014 at 14:47
  • I think it would be helpful if you'd show an excerpt of how the final array should look like. Just saying it should be two dimensional is really not enough. How should the outer array be indexed? By number or filename? And what about the inner array keys? filesize and filemtime, or numerically 0, 1? Commented Feb 13, 2014 at 14:53

1 Answer 1

2
$data = array();
foreach($tabelka as $filename) {
   $data[$filename] = array('mtime' => filemtime($filename), 'size' => filesize($filename));
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.