3v4l.org

run code in 300+ PHP versions simultaneously
<?php $prvi = [ 'jabolka' => 'Jabolka', 'hruske' => 'Hruške' ]; $drugi = [ 'borovnice' => 'Borovnice', 'pomarance' => 'Pomaranče' ]; array_splice_preserve_keys( $prvi, 1, null, $drugi ); echo '<pre>'.print_r($prvi, true).'</pre>'; function array_splice_preserve_keys(&$input, $offset, $length=null, $replacement=array()) { if (empty($replacement)) { return array_splice($input, $offset, $length); } $part_before = array_slice($input, 0, $offset, $preserve_keys=true); $part_removed = array_slice($input, $offset, $length, $preserve_keys=true); $part_after = array_slice($input, $offset+$length, null, $preserve_keys=true); $input = $part_before + $replacement + $part_after; return $part_removed; }
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 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
<pre>Array ( [jabolka] => Jabolka [borovnice] => Borovnice [pomarance] => Pomaranče [hruske] => Hruške ) </pre>
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 <pre>Array ( [jabolka] => Jabolka [borovnice] => Borovnice [pomarance] => Pomaranče [hruske] => Hruške ) </pre>

preferences:
177.65 ms | 402 KiB | 200 Q