3v4l.org

run code in 300+ PHP versions simultaneously
<?php class t { private static $configs = ["a" => ["b" => "c"]]; public static function set($name, $value) { $keyParts = explode(".", $name); $config =& self::$configs; while (!empty($keyParts)) { $key = array_shift($keyParts); if (!isset($config[$key])) { $config[$key] = []; } if (empty($keyParts)) { $config[$key] = $value; return; } $tconfig =& $config[$key]; $config = $tconfig; } } private static function getKey($parts, $config = null) { if (is_null($config)) { $config =& self::$configs; } return self::findKey($parts, $config, true); } private static function findKey($keyParts, &$array, $returnValue = false) { $key = array_shift($keyParts); if (!isset($array[$key])) { return false; } if (empty($keyParts)) { if ($returnValue) { return $array[$key]; } return true; } return self::findKey($keyParts, $array[$key], $returnValue); } public static function dump() { var_dump(self::$configs); } } t::set("a.b", "vittu"); t::dump();
Output for git.master, git.master_jit, rfc.property-hooks
array(1) { ["b"]=> string(5) "vittu" }

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