Re: cvs: php4 /ext/standard array.c
| From: | Jeroen van Wolffelaar | Date: | Fri, 05 Oct 2001 20:42:18 +0000 |
| Subject: | Re: cvs: php4 /ext/standard array.c | ||
| References: | 1 | Groups: | php.cvs php.dev |
| Request: | Send a blank email to php-dev+get-67380@lists.php.net to get a copy of this message | ||
Because for some reason php_search_array decides to not stop at first
match, but take the last match when returning keys... I don't understand
why. Any objections against stopping at first match? That's the quickest
for this function, since you don't need to go through the whole array if
the match is near the beginning anymore.
I was going to add a test anyway, because this is a typical function
which NEEDS a test...
--Jeroen
On Fri, 5 Oct 2001, Edin Kadribasic wrote:
> Hi Jeroen,
>
> Why does this:
>
> $a=array(1=>'a', 2=>'b');
> $c=array_search ('b', $a);
> $d=in_array ('b', $a);
> var_dump($c);
> var_dump($d);
>
> prints:
>
> bool(false)
> bool(true)
>
> Edin
> ----- Original Message -----
> From: "Jeroen van Wolffelaar" <jeroen@A-Eskwadraat.nl>
> To: <php-cvs@lists.php.net>
> Sent: Friday, October 05, 2001 10:14 PM
> Subject: [PHP-CVS] cvs: php4 /ext/standard array.c
>
>
> > jeroen Fri Oct 5 16:14:33 2001 EDT
> >
> > Modified files:
> > /php4/ext/standard array.c
> > Log:
> > Fix bug 13567 and don't depend on a boolean int-value to be either 1 or
> 0
> >
> >
> > Index: php4/ext/standard/array.c
> > diff -u php4/ext/standard/array.c:1.138 php4/ext/standard/array.c:1.139
> > --- php4/ext/standard/array.c:1.138 Fri Oct 5 14:38:51 2001
> > +++ php4/ext/standard/array.c Fri Oct 5 16:14:33 2001
> > @@ -21,7 +21,7 @@
> >
> +----------------------------------------------------------------------+
> > */
> >
> > -/* $Id: array.c,v 1.138 2001/10/05 18:38:51 edink Exp $ */
> > +/* $Id: array.c,v 1.139 2001/10/05 20:14:33 jeroen Exp $ */
> >
> > #include "php.h"
> > #include "php_ini.h"
> > @@ -1071,7 +1071,7 @@
> > zend_hash_internal_pointer_reset_ex(target_hash, &pos);
> > while(zend_hash_get_current_data_ex(target_hash, (void **)&entry, &pos)
> == SUCCESS) {
> > compare_func(&res, *value, *entry TSRMLS_CC);
> > - if (Z_LVAL(res) == 1) {
> > + if (Z_LVAL(res)) {
> > if (behavior==0) {
> > RETURN_TRUE;
> > } else {
> > @@ -1090,11 +1090,7 @@
> > zend_hash_move_forward_ex(target_hash, &pos);
> > }
> >
> > - if (behavior == 0) {
> > - RETURN_FALSE;
> > - } else {
> > - return;
> > - }
> > + RETURN_FALSE;
> > }
> >
> >
> >
> >
> >
> > --
> > PHP CVS Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-cvs-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-cvs-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
> >
> >
>
>
Jeroen van Wolffelaar
Jeroen@A-Eskwadraat.nl
http://www.A-Eskwadraat.nl/~jeroen