- 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] =
$filesContent[$fileName][$languageKey][$key]
?? $values[$languageKey]
?? '';
}
var_export($original);