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);
Output for git.master_jit, git.master, rfc.property-hooks
Parse error: syntax error, unexpected token "public", expecting end of file in /in/1tM98 on line 2
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:
161.99 ms | 1008 KiB | 7 Q