Re: [PHP] strange empty array behavior being at in_array()

2001-12-24 Thread Bogdan Stancescu

RTFM: http://www.php.net/manual/en/language.types.type-juggling.php

Peter Vereshagin wrote:

> Bogdan Stancescu wrote:
> >
> > Try in_array('pattern',array('')) and in_array(1,array(0)). The quirk you
> > found is predictable, as we know how PHP behaves when converting strings to
> > integer values...
>
> you mean PHP converts string pattern to integer before apply pattern?
> But what's the kind of technique? ASCII?
>
> > And 'pattern' evaluates to 0 -- '55pattern' for example
> > doesn't match -- but then again, what kinda word is that? :-)
>
> I see no reason not to consider it to evaluate to 0 the same way:)
> Either, you probably mean digits' sense? what kind of?
>
> > Peter Vereshagin wrote:
> >
> > > I think that would not be PHP error. But what's the thing I
> > > misunderstood?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] strange empty array behavior being at in_array()

2001-12-24 Thread Peter Vereshagin

Bogdan Stancescu wrote:
> 
> Try in_array('pattern',array('')) and in_array(1,array(0)). The quirk you
> found is predictable, as we know how PHP behaves when converting strings to
> integer values... 

you mean PHP converts string pattern to integer before apply pattern?
But what's the kind of technique? ASCII?

> And 'pattern' evaluates to 0 -- '55pattern' for example
> doesn't match -- but then again, what kinda word is that? :-)

I see no reason not to consider it to evaluate to 0 the same way:)
Either, you probably mean digits' sense? what kind of?


> Peter Vereshagin wrote:
> 
> > I think that would not be PHP error. But what's the thing I
> > misunderstood?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] strange empty array behavior being at in_array()

2001-12-24 Thread Bogdan Stancescu

Try in_array('pattern',array('')) and in_array(1,array(0)). The quirk you
found is predictable, as we know how PHP behaves when converting strings to
integer values... And 'pattern' evaluates to 0 -- '55pattern' for example
doesn't match -- but then again, what kinda word is that? :-)

HTH

Bogdan

Peter Vereshagin wrote:

> I think that would not be PHP error. But what's the thing I
> misunderstood?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] strange empty array behavior being at in_array()

2001-12-24 Thread Peter Vereshagin

I wonder why something non-empty is considered to be an empty array
element:
===
if ( in_array('pattern', array( 0 ) ) )
   print "Got it";
===
I got the true condition. However, after I populate the array with
antries other than 0 and ''
the condition fails.
I think that would not be PHP error. But what's the thing I
misunderstood?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]