3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Example; function substr_replace( array|string $string, array|string $replace, array|int|null $offset, array|int|null $length = null ): string|array { if ( $offset === null ) { $offset = is_string($string) ? strlen($string) : array_map(strlen(...), $string); } return \substr_replace($string, $replace, $offset, $length); } $foo = substr_replace('abc', 'xyz', null); var_dump($foo); $foo = substr_replace(['hello', 'goodbye'], '!', null); var_dump($foo); $foo = substr_replace(['one', 'two'], [' - uno', ' - dos'], null); var_dump($foo);
Output for git.master, git.master_jit, rfc.property-hooks
string(6) "abcxyz" array(2) { [0]=> string(6) "hello!" [1]=> string(8) "goodbye!" } array(2) { [0]=> string(9) "one - uno" [1]=> string(9) "two - dos" }

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:
131.83 ms | 1399 KiB | 10 Q