I'm creating a symfony2 application that searches and replaces strings from files
I created a yaml file with the following content:
parameters:
file.search_and_replace:
"path/dir/filename":
replace: 'word'
with: 'anotherword'
"path_2/dir/filename_2":
replace: 'apples'
with: 'oranges'
now to fetch the content I use the following syntax:
$array = $this->getContainer()->getParameter('file.search_and_replace');
If I dump the variable like this:
var_dump($array);
it returns
array(2)
{
'path/file/filename' =>
array(2)
{
'replace' => string(4) "word"
'with' => string(11) "anotherword"
}
'path_2/file/filename_2' =>
array(2)
{
'replace' => string(6) "apples"
'with' => string(7) "oranges"
}
}
I need to find a way to loop through this array so I can pass the content to a function I created, that needs the following parameters:
searchAndReplace('filepath','replace_this_word','with_this_word');
something like:
foreach($array as $file)
{
searchAndReplace($file.path,$file.replace,$file.with);
}