3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ "", true, false, null, "\x0", 0, "0", ]; var_export( substr_replace($array, 'prefix_', 0, 0) ); echo "\n---\n"; var_export( preg_replace('/^/', 'prefix_', $array) ); echo "\n===\n"; var_export( preg_replace('/$/', '_suffix', $array) ); echo "\n===\n"; var_export( substr_replace(null, 'prefix_', 0, 0) ); echo "\n---\n"; var_export( preg_replace('/^/', 'prefix_', null) );
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
array ( 0 => 'prefix_', 1 => 'prefix_1', 2 => 'prefix_', 3 => 'prefix_', 4 => 'prefix_' . "\0" . '', 5 => 'prefix_0', 6 => 'prefix_0', ) --- array ( 0 => 'prefix_', 1 => 'prefix_1', 2 => 'prefix_', 3 => 'prefix_', 4 => 'prefix_' . "\0" . '', 5 => 'prefix_0', 6 => 'prefix_0', ) === array ( 0 => '_suffix', 1 => '1_suffix', 2 => '_suffix', 3 => '_suffix', 4 => '' . "\0" . '_suffix', 5 => '0_suffix', 6 => '0_suffix', ) === Deprecated: substr_replace(): Passing null to parameter #1 ($string) of type array|string is deprecated in /in/ENVip on line 26 'prefix_' --- Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/ENVip on line 30 'prefix_'

preferences:
105.43 ms | 403 KiB | 61 Q