PHP 4.0 Bug #6346: preg_replace with arrays truncates results
| From: | rick at eastcore dot net | Date: | Fri, 25 Aug 2000 08:43:28 +0000 |
| Subject: | PHP 4.0 Bug #6346: preg_replace with arrays truncates results | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-30607@lists.php.net to get a copy of this message | ||
From: rick@eastcore.net
Operating system: Linux (2.2.16)
PHP version: 4.0.1pl2
PHP Bug Type: Misbehaving function
Bug description: preg_replace with arrays truncates results
I noticed that a system which worked fine with PHP3
broke under PHP4. In tracking down the problem I found
that preg_replace was the source of the difficulty.
The following simple PHP script truncates the returned
string:
<?
$text = "this is some test textthis is some test textthis is some test textthis is some
test textthis is some test textthis is some
test textthis is some test textthis is some test textthis is some test textthis is some test
textthis is some test textthis is some test
textthis is some test textthis is some test textthis is some test textthis is some test textthis is
some test textthis is some test tex
tthis is some test textthis is some test textthis is some test textthis is some test textthis is
some test textthis is some test textthi
s is some test textthis is some test textthis is some test textthis is some test textthis is some
test textthis is some test textthis is
some test textthis is some test textthis is some test textthis is some test textthis is some test
text\n";
$array1 = array();
$array2 = array();
$text2 = preg_replace($array1, $array2, $text);
print "text = $text2<br>\n";
?>
It appears that using empty array(s) in a preg_replace
truncates the string returned -- which differs significantly
from the no-op behavior in php3.
The configure command is:
configure --with-mysql=/usr --enable-versioning --with-apache=../apache_1.3.12