On Tue, Feb 20, 2001 at 08:27:59AM -0600, Andrei Zmievski wrote:
in_array() used to move the pointer to the entry found, but people
complained about it so I remove it... :)
And I thought it was neat, can't please everyone I guess (:
There seems to be a general problem with array functions and
ID: 9337
Updated by: jason
Reported By: [EMAIL PROTECTED]
Old-Status: Assigned
Status: Closed
Bug Type: Feature/Change Request
Assigned To: [EMAIL PROTECTED]
Comments:
Request complete, new function created called array_search in CVS. Check it out in
snapshots.
-Jason
Previous Comments:
ID: 9337
Updated by: andre
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Feedback
Bug Type: Feature/Change Request
Assigned To:
Comments:
maybe a fourth parameter switch to avoid 0-false problems?
Previous Comments:
How about using array_keys($array, $value) to find the key?
obviously it is cheaper to let in_array return it and it is more php 4
stylish, we have booleans, why not use them?
if ($key=in_array()) do_someting_with_key($key);
is less expensive than
if (in_array()) {
-
From: "Andrei Zmievski" [EMAIL PROTECTED]
To: "Andr Langhorst" [EMAIL PROTECTED]
Cc: "PHP Development" [EMAIL PROTECTED]
Sent: Monday, February 19, 2001 11:36 AM
Subject: Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if
searched value was fou
On Mon, 19 Feb 2001, Jason Greene wrote:
Some of my thoughts:
1. if you change the return value of in_array to return the key, you can get a false
error
in your if statement, imagine if in_array found the element in key 0? : )
2. I would say that returning a key is a bit more useful then an
Cc: "Andr Langhorst" [EMAIL PROTECTED]; "PHP Development" [EMAIL PROTECTED]
Sent: Monday, February 19, 2001 11:50 AM
Subject: Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if
searched value was found
On Mon, 19 Feb 2001, Jason Greene wrote:
Some of my thoug
On Mon, 19 Feb 2001, Jason Greene wrote:
We can change in_array() to return the the key if it's found, and false
if it's not, but imagine all the scripts it would break..
about 1/4th of mine : )
Well I think the basic problem is that people are using in_array against its
intention.
It
TED]; "PHP Development" [EMAIL PROTECTED]
Sent: Monday, February 19, 2001 12:02 PM
Subject: Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if
searched value was found
On Mon, 19 Feb 2001, Jason Greene wrote:
We can change in_array() to return the the
Could be done. The way I'd do it is have one php_in_array() C function
that gets parameters passed through from in_array() and array_find() as
well as a flag indicating whether to just return true/false or the
actual key.
what about not touching the internal pointer? there in_array would
10 matches
Mail list logo