3v4l.org

run code in 300+ PHP versions simultaneously
<?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] = isset($values[$languageKey]) ? $values[$languageKey] : isset($filesContent[$fileName][$languageKey][$key]) ? $filesContent[$fileName][$languageKey][$key] : ''; } var_export($original);
Output for 8.0.0 - 8.0.10
Fatal error: Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /in/9CvDA on line 17
Process exited with code 255.
Output for 7.4.0 - 7.4.23
Deprecated: Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /in/9CvDA on line 17 array ( 'en' => '', 'es' => 'Spanish2', 'fr' => 'French', )
Output for 7.2.33 - 7.2.34, 7.3.0 - 7.3.30
array ( 'en' => '', 'es' => 'Spanish2', 'fr' => 'French', )

preferences:
208.68 ms | 1399 KiB | 73 Q