B
B
Bobur Bakhritdinov2016-01-10 18:20:15
PHP
Bobur Bakhritdinov, 2016-01-10 18:20:15

[PHP] - Is the array acting strange or did I make a mistake somewhere?

Hello everyone, please help me solve this problem!
There is a code that generates a list of file names from a torrent.

<?
require 'system/functions/functions.benc.php';

$dict = bdec_file('public/test.torrent', (1024 * 1024) );

if(is_array($dict)){
foreach($dict['value']['info']['files']['value'] as $file){
  $length = $file['value']['length']['value']; // размер
  $filename = $file['value']['path']['value'][0]['value']; // имя файла 
  }
}
?>

Here are all the sources:
Sources
But gives an error:
Warning: Invalid argument supplied for foreach() in /var/www/example.php on line 9
9 line is :
<?
foreach($dict['value']['info']['files']['value'] as $file){
  $length = $file['value']['length']['value']; // размер
  $filename = $file['value']['path']['value'][0]['value']; // имя файла 
}
?

Loop, the error says that the array is empty, but it's not) the $dict variable contains the data from the torrent. in source codes there are results of inquiry Result
Help to form a name of a folder and files correctly. I will be very grateful for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivanq, 2016-01-10
@bakhritdinov_b

$dict['value']['info']['value']['files']['value']
Forgot to write ['value'] after ['info']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question