3v4l.org

run code in 300+ PHP versions simultaneously
<?php //Enter your code here, enjoy! $array = [ 'database' => [ 'host' => 'localhost', 'db_name' => 'test', 'user' => 'root', 'password' => '' ], 'locale' => [ 'timezone' => 'Europe/Rome', 'default_language' => 'en' ], 'mailer' => [ 'system' => 'phpmail' ], 'session' => [ 'id' => 'vela_id' ] ]; /** * Config class * * Simple class to store or get elements from configuration registry */ class Config implements \ArrayAccess { /** @var array $data Data configuration array */ private $data = []; /** * Class constructor * @param array $data List of values to add to the configuration registry */ public function __construct(array $data = []) { $this->data = $data; } /** * Retrieves elements from config array * * @param string $key * @return mixed returns a config value * @throws Exception when no $key found */ public function get($key) { $segments = explode('.', $key); $data = $this->data; foreach ($segments as $segment) { if (isset($this->data[$segment])) { $this->data = $$this->data[$segment]; } else { $this->data = null; break; } } return $this->data; } /** * Return true if value is empty for given key * * @param string $key * @return bool */ public function isEmpty($key) { return empty($this->data[$key]); } /** * Key to set * * @param mixed $key * @param mixed $value * @throws \Exception */ public function offsetSet($key, $value) { if (!$key) { $this->data[] = $value; } else { $this->data[$key] = $value; } } /** * Key to retrieve * * @param mixed $key * @return string|null */ public function offsetGet($key) { if (isset($this->data[$key])) { return $this->data[$key]; } return null; } /** * Whether a key exists * * @param mixed $key * @return bool */ public function offsetExists($key) { return isset($this->data[$key]); } /** * Key to unset * * @param mixed $key */ public function offsetUnset($key) { unset($this->data[$key]); } } $config = new Config($array); var_dump($config->get('database.host'));

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.40.0040.01118.88
8.3.30.0070.00718.78
8.3.20.0080.00020.20
8.3.10.0000.00823.70
8.3.00.0080.00019.97
8.2.170.0100.01022.96
8.2.160.0030.01020.39
8.2.150.0030.00624.18
8.2.140.0050.00324.66
8.2.130.0040.00420.95
8.2.120.0000.00826.35
8.2.110.0100.00019.12
8.2.100.0130.00017.91
8.2.90.0040.00419.40
8.2.80.0000.00817.97
8.2.70.0040.00417.63
8.2.60.0040.00417.93
8.2.50.0050.00218.07
8.2.40.0040.00421.18
8.2.30.0030.00720.72
8.2.20.0040.00417.76
8.2.10.0000.00718.07
8.2.00.0080.00018.07
8.1.270.0040.00418.95
8.1.260.0000.00728.09
8.1.250.0050.00228.09
8.1.240.0030.00621.29
8.1.230.0040.00817.58
8.1.220.0000.00817.76
8.1.210.0060.00318.77
8.1.200.0030.00617.48
8.1.190.0040.00417.53
8.1.180.0030.00518.10
8.1.170.0060.00318.59
8.1.160.0040.00420.74
8.1.150.0070.00018.83
8.1.140.0040.00419.53
8.1.130.0040.00417.64
8.1.120.0040.00417.57
8.1.110.0000.00817.46
8.1.100.0000.00817.39
8.1.90.0000.00717.39
8.1.80.0000.00717.36
8.1.70.0070.00017.45
8.1.60.0040.00417.63
8.1.50.0040.00417.52
8.1.40.0040.00417.55
8.1.30.0040.00417.72
8.1.20.0040.00417.63
8.1.10.0050.00317.59
8.1.00.0060.00317.51
8.0.300.0050.00318.77
8.0.290.0020.00516.75
8.0.280.0000.00718.48
8.0.270.0000.00717.31
8.0.260.0060.00017.35
8.0.250.0070.00017.02
8.0.240.0030.00317.00
8.0.230.0070.00017.05
8.0.220.0000.00816.86
8.0.210.0040.00417.02
8.0.200.0040.00416.98
8.0.190.0000.00716.97
8.0.180.0040.00417.02
8.0.170.0040.00416.97
8.0.160.0070.00017.01
8.0.150.0040.00416.94
8.0.140.0070.00016.82
8.0.130.0000.00613.38
8.0.120.0050.00316.88
8.0.110.0000.00716.89
8.0.100.0040.00416.95
8.0.90.0040.00416.96
8.0.80.0040.01316.97
8.0.70.0030.00517.02
8.0.60.0040.00416.78
8.0.50.0000.00716.96
8.0.30.0070.01217.15
8.0.20.0110.01217.40
8.0.10.0050.00217.15
8.0.00.0080.01016.73
7.4.330.0050.00215.09
7.4.320.0000.00616.64
7.4.300.0000.00716.55
7.4.290.0090.00016.55
7.4.280.0000.00816.61
7.4.270.0050.00316.64
7.4.260.0040.00416.41
7.4.250.0040.00416.37
7.4.240.0000.00716.51
7.4.230.0030.00316.69
7.4.220.0090.00616.63
7.4.210.0030.01016.57
7.4.200.0000.00716.47
7.4.160.0090.00616.47
7.4.150.0090.00917.40
7.4.140.0110.01217.86
7.4.130.0140.00516.53
7.4.120.0080.01016.52
7.4.110.0120.00616.60
7.4.100.0030.01316.58
7.4.90.0040.01316.46
7.4.80.0100.00719.39
7.4.70.0030.01316.66
7.4.60.0070.01316.69
7.4.50.0030.01016.42
7.4.40.0150.00916.73
7.4.30.0030.01516.40
7.4.00.0070.01115.05
7.3.330.0000.00513.36
7.3.320.0070.00013.23
7.3.310.0060.00316.34
7.3.300.0040.00416.26
7.3.290.0050.01016.37
7.3.280.0070.00916.43
7.3.270.0250.00917.40
7.3.260.0090.00916.41
7.3.250.0120.00716.43
7.3.240.0140.00316.59
7.3.230.0090.00916.44
7.3.210.0030.01416.67
7.3.200.0090.00916.45
7.3.190.0340.02116.56
7.3.180.0130.00316.61
7.3.170.0120.00916.46
7.3.160.0030.01316.31
7.3.120.0070.01014.88
7.3.110.0050.01114.94
7.3.100.0030.01314.83
7.3.90.0050.00714.95
7.3.80.0020.01014.91
7.3.70.0050.00914.79
7.3.60.0050.00714.77
7.3.50.0070.00414.77
7.3.40.0040.01314.86
7.3.30.0080.00514.71
7.3.20.0030.01016.74
7.3.10.0050.00916.77
7.3.00.0050.00816.73
7.2.330.0070.01116.61
7.2.320.0060.01116.82
7.2.310.0060.01616.82
7.2.300.0060.01216.88
7.2.290.0070.01016.57
7.2.250.0100.01015.28
7.2.240.0090.00915.15
7.2.230.0070.00914.94
7.2.220.0070.00415.15
7.2.210.0060.00915.26
7.2.200.0080.00715.11
7.2.190.0050.01015.18
7.2.180.0070.01015.22
7.2.170.0030.01314.88
7.2.160.0040.00714.96
7.2.150.0060.00916.89
7.2.140.0040.00717.06
7.2.130.0040.00817.14
7.2.120.0060.00616.98
7.2.110.0060.00716.96
7.2.100.0040.01116.97
7.2.90.0060.00317.17
7.2.80.0090.00617.09
7.2.70.0040.01416.80
7.2.60.0090.00416.94
7.2.50.0800.00716.77
7.2.40.0050.00816.84
7.2.30.0060.00616.96
7.2.20.0080.00816.79
7.2.10.0240.01016.81
7.2.00.0080.01518.19
7.1.330.0050.01015.64
7.1.320.0080.00515.66
7.1.310.0050.00915.83
7.1.300.0070.00515.73
7.1.290.0130.00715.73
7.1.280.0050.00715.79
7.1.270.0100.00515.81
7.1.260.0050.00515.69
7.1.250.0000.01415.63
7.1.200.0060.00615.88
7.1.100.0030.00718.29
7.1.70.0100.00017.32
7.1.60.0130.01319.50
7.1.50.0100.01016.80
7.1.00.0000.07722.30
7.0.200.0030.00616.50
7.0.60.0130.05719.81
7.0.50.0100.06717.91
7.0.40.0100.08320.13
7.0.30.0370.06320.07
7.0.20.0330.07320.01
7.0.10.0130.08020.10
7.0.00.0000.07320.11
5.6.210.0130.08320.54
5.6.200.0030.09318.22
5.6.190.0100.07720.51
5.6.180.0470.05320.33
5.6.170.0300.05720.51
5.6.160.0170.07020.55
5.6.150.0070.06018.16
5.6.140.0100.07318.24
5.6.130.0030.08318.27
5.6.120.0030.06321.11
5.6.110.0030.08021.00
5.6.100.0000.08721.04
5.6.90.0030.08720.99
5.6.80.0000.07320.38
5.5.350.0070.08320.32
5.5.340.0100.07017.99
5.5.330.0100.07020.31
5.5.320.0070.07720.41
5.5.310.0200.04020.30
5.5.300.0100.06317.95
5.5.290.0070.08317.94
5.5.280.0100.07020.81
5.5.270.0100.05020.99
5.5.260.0030.09020.79
5.5.250.0100.07720.63
5.5.240.0100.04020.18

preferences:
56.17 ms | 400 KiB | 5 Q