3v4l.org

run code in 500+ PHP versions simultaneously
<?php $fileContents = <<<TEXT 1|2 2|6 3|8 4|3 5|10 TEXT; $_GET['candidate'] = '4'; if (isset($_GET['candidate'])) { $fileContents = preg_replace_callback( '~^' . (int)$_GET['candidate'] . '\|\K\d+~m', function($m) { return ++$m[0]; }, $fileContents ); echo "New total: " . array_sum(preg_match_all('~\|\K\d+~', $fileContents, $m) ? $m[0] : []); echo "\n---\n"; echo $fileContents; //file_put_contents('results.txt', $fileContents); }
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.4, 8.3.6 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
New total: 30 --- 1|2 2|6 3|8 4|4 5|10
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 New total: 30 --- 1|2 2|6 3|8 4|4 5|10

preferences:
94.24 ms | 1378 KiB | 4 Q