3v4l.org

run code in 300+ PHP versions simultaneously
<?php function match($available, $opened, $closed) { $last_open = $opened[count($opened) - 1]; if ($available[$last_open] !== $closed[0]) { return 'NO'; } match($available, array_slice($opened, 0, -1), array_slice($closed, 1)); return 'YES'; } function isValid($braces) { $available = ['{' => '}', '(' => ')', '[' => ']']; $opened = []; $closed = []; for ($i = 0; $i < count($braces) - 1; $i++) { if (in_array($braces[$i], array_keys($available))) { $opened[] = $braces[$i]; continue; } $closed[] = $braces[$i]; } return match($available, $opened, $closed); } function braceCheck($values) { for ($i = 0; $i < count($values) - 1; $i++) { $braces = str_split($value); $values[$i] = isValid($braces); } return $values; } echo 'dessert<br>'; $values = ['{}()[]', '{]}[']; var_dump($values); ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Parse error: syntax error, unexpected token "match", expecting "(" in /in/2CB7K on line 3
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Parse error: syntax error, unexpected token "match", expecting "(" in /in/2CB7K on line 3
Process exited with code 255.
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
dessert<br>array(2) { [0]=> string(6) "{}()[]" [1]=> string(4) "{]}[" }

preferences:
136.53 ms | 402 KiB | 162 Q