0
foreach($files as $filename) {
		$file2 = $file2.$filename."<br />";
		echo $file2;
	}

What is wrong with this foreach loop? I just cannot figure it out. It is supposed to take the value from $files and store it in $filename. It's not doing this. It says $filename is an Array. I don't use $filename anywhere else in the entire script. This has me stumped and I'm sure $files is an array.

Also, this isn't the only foreach loop in my script that's doing this.

Edited by baudday: n/a

3
Contributors
7
Replies
8
Views
8 Years
Discussion Span
Last Post by baudday
0

check the $files array, you may have an array as value. Try print_r to make sure what the contents of the $files array is

grtzzzzz
Michael

0

Yeah $files is an array, not the value "Array." I'm sure of this.

0
array(4) { [0]=>  string(25) "./Crookers - Knobbers.mp3" [1]=>  string(61) "./Lil' Wayne/Lil Wayne - Da Drought Vol.3/CD 1/03.Upgrade.mp3" [2]=>  string(61) "./Lil' Wayne/Lil Wayne - Da Drought Vol.3/CD 1/13.Promise.mp3" [3]=>  string(60) "./Lil' Wayne/Lil Wayne - Da Drought Vol.3/CD 2/05.Dipset.mp3" }
0

Looks like $filename is an array of arrays, try

foreach ($files as $file_list) {
  foreach ($file_list as $file) {
    var_dump($file); echo "\n";
  }
}
0

Alright that kind of works. However one of the values is getting saved into the array of arrays like 3 times now. Any reason why it would make it an array of arrays? I just want one single array with values.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.