#44925 [Asn]: preg_grep and array index - follow up on #44191

From: Date: Thu, 17 Jul 2008 15:46:27 +0000
Subject: #44925 [Asn]: preg_grep and array index - follow up on #44191
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-126896@lists.php.net to get a copy of this message
 ID:          44925
 Updated by:  nlopess@php.net
 Reported By: admin at ifyouwantblood dot de
 Status:      Assigned
 Bug Type:    PCRE related
 PHP Version: 5.2.6
 Assigned To: nlopess
 New Comment:

non, really. It's just that the code will become much bigger to do the
copying :)


Previous Comments:
------------------------------------------------------------------------

[2008-07-13 16:18:18] jani@php.net

Functions should never ever modify the input array unless designed to
do so. According to documentation, preg_grep() is not supposed to modify
the input array. So it's a bug, not BC. What exactly is the usage case
where it should modify input array?

------------------------------------------------------------------------

[2008-07-06 18:46:13] nlopess@php.net

I don't really know what to do with this..
While I agree it shouldn't modify the original array, changing the
behavior would break BC.. Any opinions about this?

------------------------------------------------------------------------

[2008-05-06 16:00:03] admin at ifyouwantblood dot de

> PHP obviously should convert the values to string to be used in
> regex matching. Hence, i think that it should returns the string
> that was matched.

sure, internally it'll has to be converted, but i see no reason for a
change of the input array. thus preg_grep should work with a copy of the
input array...

------------------------------------------------------------------------

[2008-05-06 13:07:09] felipe@php.net

Well, preg_grep() != in_array()...
PHP obviously should convert the values to string to be used in regex
matching. Hence, i think that it should returns the string that was
matched.

Anyway, i'll assign to the maintainer to solve this issue.

Thanks.

------------------------------------------------------------------------

[2008-05-06 12:48:29] admin at ifyouwantblood dot de

>> this is a follow up on bug #44191. that was fixed, but everything
>> inside the array is now converted to a string. as i understand it,
>> the search array shouldn't change at all, so i think this is a
>> bug. please note that with objects without a __toString() method, >>
this of course leads to a fatal error.
>
> This is expected, the function is for matching strings.

sorry, but did you even take a look at the samples? preg_grep is a
SEARCH function, why should it change the INPUT array?

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/44925

-- 
Edit this bug report at http://bugs.php.net/?id=44925&edit=1



Thread (9 messages)

« previous php.bugs (#126896) next »