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) { if(isset($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"); var_dump($translations[$lang][$key]);
Output for git.master, git.master_jit
missing key testkey2_fr Warning: Undefined variable $lang in /in/qSnmF on line 22 Warning: Undefined array key "" in /in/qSnmF on line 22 Warning: Undefined variable $key in /in/qSnmF on line 22 Warning: Trying to access array offset on value of type null in /in/qSnmF on line 22 NULL
Output for rfc.property-hooks
missing key testkey2_fr Warning: Undefined variable $lang in /in/qSnmF on line 22 Warning: Undefined array key "" in /in/qSnmF on line 22 Warning: Undefined variable $key in /in/qSnmF on line 22 Warning: Trying to access array offset on null in /in/qSnmF on line 22 NULL

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:
40.18 ms | 401 KiB | 8 Q