Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found

2001-02-20 Thread Jason Greene
Andrei Zmievski wrote: > > On Tue, 20 Feb 2001, Stig Venaas wrote: > > I could in order to save the position do $key = key($arr). To > > restore it later, I could then do something like array_setpos($key). > > I'm not sure if the Zend API allows for setting the position without > > looping throu

Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found

2001-02-20 Thread Andrei Zmievski
On Tue, 20 Feb 2001, Stig Venaas wrote: > I could in order to save the position do $key = key($arr). To > restore it later, I could then do something like array_setpos($key). > I'm not sure if the Zend API allows for setting the position without > looping through the array though. If array_setpos(

Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found

2001-02-20 Thread Stig Venaas
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 an

Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found

2001-02-20 Thread Andrei Zmievski
On Tue, 20 Feb 2001, Stig Venaas wrote: > Not quite sure we need array_find(). If we can have in_array() set > the array pointer to point to the entry found, one can get the key > by using key(). If in_array() also searches from the pointer onwards, > one can find all entries with the value by doi

Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found

2001-02-19 Thread Stig Venaas
On Mon, Feb 19, 2001 at 12:02:48PM -0600, Andrei Zmievski wrote: > 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 thin

Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found

2001-02-19 Thread André Langhorst
> 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

Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found

2001-02-19 Thread Jason Greene
anghorst" <[EMAIL PROTECTED]>; "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: > > >

Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found

2001-02-19 Thread Andrei Zmievski
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

Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found

2001-02-19 Thread Jason Greene
reene" <[EMAIL PROTECTED]> 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

Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found

2001-02-19 Thread Andrei Zmievski
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

Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found

2001-02-19 Thread Jason Greene
- 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

Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found

2001-02-19 Thread Andrei Zmievski
On Mon, 19 Feb 2001, André Langhorst wrote: > > 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); So, you sug

Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found

2001-02-19 Thread André Langhorst
> 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()) { $key=array_keys($arra

Re: [PHP-DEV] PHP 4.0 Bug #9337 Updated: make in_array return key, if searched value was found

2001-02-19 Thread Andrei Zmievski
How about using array_keys($array, $value) to find the key? On Mon, 19 Feb 2001, [EMAIL PROTECTED] wrote: > 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 parame