3v4l.org

run code in 300+ PHP versions simultaneously
<?php $translations = ["testkey" => ["de" => "TESTKEYDEUTSCH", "en" => "TESTKEYENGLISH"], "testkey2" => ["de" => "TESTKEYDEUTSCH", "en" => "TESTKEYENGLISH"], ]; function stringByLanguage($key, $lang) { var_dump($translations); if(array_key_exists($key, $translations)){ var_dump(array_key_exists($key, $translations["key"])); if(isset($translations[$key][$lang])){ return $translations[$key][$lang]; } elseif (isset($translations[$key]["de"])) { return $translations[$key]["de"]; } } return "missing key ".$key."_".$lang; } echo stringByLanguage("testkey2","fr");
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $translations in /in/rWDZU on line 10 NULL Warning: Undefined variable $translations in /in/rWDZU on line 11 Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in /in/rWDZU:11 Stack trace: #0 /in/rWDZU(22): stringByLanguage('testkey2', 'fr') #1 {main} thrown in /in/rWDZU on line 11
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
47.33 ms | 401 KiB | 8 Q