Well first you you will want to read up on the [man]filesystem[/man]'s in the manual
The functions you will want to look at are [man]basename[/man] and [man]pathinfo[/man] for retrieving the files name. And you will likely want to use [man]file[/man] to parse a files rows into an array.
And then for both the file name and file rows you will need to use [man]explode[/man], to get the various parts separated out.