- var_export: documentation ( source)
<?php
$allLanguages = ['en', 'es', 'fr'];
$values = ['es' => 'Spanish1'];
$filesContent = [
'foo' => [
'es' => ['bar' => 'Spanish2'],
'fr' => ['bar' => 'French']
]
];
$fileName = 'foo';
$key = 'bar';
$original = [];
foreach ($allLanguages as $languageKey) {
$original[$languageKey] =
$values[$languageKey]
?? $filesContent[$fileName][$languageKey][$key]
?? '';
}
var_export($original);