[php-src] Issue #9825: bug about preg_replace

From: Date: Tue, 25 Oct 2022 06:12:43 +0000
Subject: [php-src] Issue #9825: bug about preg_replace
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-242678@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/9825 Author: nerdpanda-ir ### Description The following code: ```php <?php $text = "welcome to this world !!! \n your name is john \n "; $result = preg_replace('/\n/',['<br>'],$text); echo $result; ``` Resulted in this output: ``` Fatal error: Uncaught TypeError: preg_replace(): Argument #1 ($pattern) must be of type array when argument #2 ($replacement) is an array, string given ``` But I expected this output instead: ``` welcome to this world !!! <br> your name is john <br> ``` i think preg_replace should automiticaly imploded replacement parameter if is array when pattern parameter is string !!! ### PHP Version PHP 8.1.2 ### Operating System Ubuntu 22.04.1 LTS

« previous php.bugs (#242678) next »