I am working with Symfony 2.6 and the application has an icons
directory inside web
directly. In icons
directory user uploads set of icons. I need to display names of those icons in a dropdown menu on a form that the twig
will display
I know how to
- Make Symfony forms to work
- Send data to twig
All I need is to assign the set of icons to an array so I can pass that to twig
I am working with Symfony Finder component use Symfony\Component\Finder\Finder;
and I can get the results I need using the following code in a controller
$finder = new Finder();
$finder->in($this->container->getParameter('icons_path'));
$finder->sortByName();
foreach ($finder as $file) {
print pathinfo($file->getRelativePathname(), PATHINFO_FILENAME)."<br>";
}
The above code gives me an output that looks like this
As you can see it is not an array. I will really appreciate if I can get some assistance on how to make this an array.
Sometimes small little things makes you go crazy This is how i did it
This is what complete foreach looks like