3v4l.org

run code in 300+ PHP versions simultaneously
<?php public static function reverse($input) { // Use regex to match "Array(...)" strings preg_match_all('/Array\(([^)]+)\)/', $input, $matches); $result = array(); foreach ($matches[1] as $match) { $result[] = self::parseArray($match); } return $result; } private static function parseArray($input) { // Use regex to match key-value pairs $matches = array(); preg_match_all("/\[(.+?)\] \=\> (.+)$/m", $input, $matches, PREG_SET_ORDER); $result = array(); foreach ($matches as $match) { $key = trim($match[1]); $value = trim($match[2]); // Recursively check if the value is another array $result[$key] = self::parseArray($value); } return $result; } // Example usage $input = " Array ( [0] => 20231219 [date] => 20231219 [1] => 9 [shine_id] => 9 [2] => 2 [nico_id] => 2 [3] => 無性に天下一品が食べたくなったので土曜行こうと思います。 [memo] => 無性に天下一品が食べたくなったので土曜行こうと思います。 ) Array ( [0] => 20231220 [date] => 20231220 [1] => 13 [shine_id] => 13 [2] => 2 [nico_id] => 2 [3] => 久々に8:30に出勤。いつもより長く寝れて気持ちが休みモードになりそうで怖かった。 [memo] => 久々に8:30に出勤。いつもより長く寝れて気持ちが休みモードになりそうで怖かった。 )"; $result = YourClassName::reverse($input); print_r($result);

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.130.0130.00616.82
8.3.120.0370.00316.18
8.3.110.0350.00616.64
8.3.100.0380.00716.43
8.3.90.0350.01016.35
8.3.80.0320.01316.92
8.3.70.0320.00816.52
8.3.60.0410.00316.73
8.3.50.0410.00316.64
8.3.40.0260.00917.50
8.3.30.0380.00017.32
8.3.20.0290.01017.67
8.3.10.0270.00917.70
8.3.00.0060.00518.99
8.2.250.0300.01016.32
8.2.240.0310.00716.60
8.2.230.0290.00916.46
8.2.220.0320.00316.42
8.2.210.0260.00916.30
8.2.200.0340.00316.36
8.2.190.0320.00716.31
8.2.180.0220.01516.77
8.2.170.0330.00717.53
8.2.160.0400.00017.58
8.2.150.0370.00317.41
8.2.140.0390.00617.58
8.2.130.0080.00619.07
8.2.120.0090.00718.96
8.2.110.0090.00518.71
8.2.100.0090.00518.87
8.2.90.0080.00619.00
8.2.80.0100.00418.50
8.2.70.0100.00318.49
8.2.60.0110.00318.39
8.2.50.0080.00518.72
8.2.40.0080.00418.78
8.2.30.0110.00218.62
8.2.20.0100.00218.94
8.2.10.0070.00518.62
8.2.00.0090.00318.86
8.1.300.0310.00316.30
8.1.290.0270.01416.18
8.1.280.0260.01316.18
8.1.270.0080.00321.59
8.1.260.0080.00421.52
8.1.250.0070.00521.52
8.1.240.0090.00218.49
8.1.230.0060.00618.48
8.1.220.0080.00318.52
8.1.210.0080.00318.42
8.1.200.0090.00318.12
8.1.190.0080.00518.30
8.1.180.0080.00518.05
8.1.170.0090.00418.11
8.1.160.0090.00418.12
8.1.150.0110.00418.39
8.1.140.0080.00418.42
8.1.130.0060.00618.57
8.1.120.0090.00318.43
8.1.110.0080.00418.48
8.1.100.0090.00418.47
8.1.90.0100.00218.55
8.1.80.0100.00218.47
8.1.70.0090.00318.73
8.1.60.0080.00619.13
8.1.50.0070.00618.80
8.1.40.0090.00418.92
8.1.30.0080.00518.86
8.1.20.0100.00318.91
8.1.10.0090.00518.55
8.1.00.0080.00518.38

preferences:
144.59 ms | 1005 KiB | 7 Q