3v4l.org

run code in 300+ PHP versions simultaneously
<?php $params = [ 'subject' => 'Hello 7', // normally third parameter 'pattern' => '/[a-z ]/', // normally first parameter // 'limit' // normally fourth parameter, omitted for this demonstration; the default -1 will be used 'count' => &$counted, // normally fifth parameter // ^-- don't forget to make it modifiable! 'replacement' => '', // normally second parameter ]; echo preg_replace(...$params) . "\n" . $counted;
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1
H7 5
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught Error: Cannot unpack array with string keys in /in/0F2Cg:11 Stack trace: #0 {main} thrown in /in/0F2Cg on line 11
Process exited with code 255.

preferences:
67.46 ms | 407 KiB | 5 Q