Re: preg_replace is changing the type of replacement parameter !!
| From: | Andrei Zmievski | Date: | Wed, 17 Oct 2001 18:20:29 +0000 |
| Subject: | Re: preg_replace is changing the type of replacement parameter !! | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-68156@lists.php.net to get a copy of this message | ||
This is fixed now.
On Thu, 13 Sep 2001, Nicolas Guilhot wrote:
> Hi guys,
>
> When I use preg_replace with an array of integer as the replacement
> parameter, this function modifies the type of each array element to string.
> I don't understand why it alters the content of the array while this
> variable is not pass by reference (True or not ??).
>
> I have just upgraded to PHP 4.0.6 and it I don't think it was the case in
> PHP 4.0.4 (the version I was using before, without this problem).
>
> Here is a short example that demonstrate my problem.
>
> <?php
> $ary_pattern = array("@One@");
> $ary_replace = array(1);
> $string_before = "One example";
> echo gettype($ary_replace[0]); // This line outputs 'integer'
> $string_after = preg_replace($ary_pattern, $ary_replace, $string_before);
> echo "<br>$string_after<br>";
> echo gettype($ary_replace[0]); // This line outputs 'string'
> ?>
>
> Is this a bug from preg_replace or am I doing wrong somewhere? Any help
> would be appreciated.
> Regards.
>
> Nicolas Guilhot
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
> For additional commands, e-mail: php-dev-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
-Andrei
* Black holes are where God divided by zero. *