metadata function not returning an array

I have a field with a list of files that I want to parse through to create a playlist. As I understand the documentation, metadata() should return an array that I put into $vfiles and then I should be able to use foreach() to loop through that array to build the playlist. The following code snippet does this:

<?php
$vfiles = metadata('item',array('Streaming Video','Video Filename'),'all');
foreach ($vfiles as $vfile) { ?>
 file: '<?php echo "$vfile"; ?>'
<?php }?>

I thought the foreach loop would have created 4 file: entries but instead it create one entry with the value of the Video Filename field like "file1, file2, file3 ..." I tried the files on separate lines and it returned "file1 file2 ..." with linebreaks. Either the metadata function is not actually returning an array or more likely, I just haven't written good code.

Thanks for any help.

Huh. I got some unexpected behavior testing this, too, and haven't been able to consistently reproduce it.

However, one thing to try might be to make the last parameter array('all'=>true) instead of just 'all'.

Thanks for the quick reply. Did try 'all' => true with the same result. Documentation (http://omeka.readthedocs.org/en/stable-2.0/Reference/libraries/globals/metadata.html) says you can use just 'all' or for an offset into the array, you can use just an integer instead of 'index' => 2. The result was the same using either 'all' or 'all' => true and I was not able to return an offset into the array using 'index' either.

Figured it out. I thought it would parse a single field in some way but you need to use the Add Input button to add multiple fields and then all the parsing of the array happens as you would expect. This can be closed now.

Problem now is I can't figure out how use CSV to load these values.

Thanks for all the help.

If you weren't getting an array back, you'd see PHP complaining about the foreach loop, since you can't loop over a string like that.

Are you sure you have multiple separate values (from separate input boxes) for that field at all?

No,I didn't have multiple boxes. That was the problem. I was returning the 0 index of the array which was the value of the one and only box I had. Once I split the list up among multiple input boxes all was well.

Thanks again,