RE: [PHP] in_array - what the...

2010-06-25 Thread Bob McConnell
From: Peter Lind

> On 25 June 2010 19:58, Bob McConnell  wrote:
>> From: Daevid Vincent
>>
>>> Why do this "in_array()" business??
>>>
>>> Just do this...
>>>
>>> if (self::$aboveArray[$name])
>>> {
>>>    //something interesting here
>>> }
>>
>> Does that gibberish actually do something? It doesn't make any sense to
>> me, while in_array() actually looks like what it does.
>>
> 
> Gibberish?? Probably a good time to go look up some php tutorials.

No thanks. I tried to figure out that double colon nonsense over a decade ago 
as part of an OOP development team. I still don't understand most of the code 
written during those two years, even though I still maintain parts of it. All I 
see is a lot of unnecessary overhead with no significant return on the 
investment. I'll stick with the tried and true procedural notation, at least 
until I retire next year.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] in_array - what the...

2010-06-25 Thread Peter Lind
On 25 June 2010 19:58, Bob McConnell  wrote:
> From: Daevid Vincent
>
>> Why do this "in_array()" business??
>>
>> Just do this...
>>
>> if (self::$aboveArray[$name])
>> {
>>    //something interesting here
>> }
>
> Does that gibberish actually do something? It doesn't make any sense to
> me, while in_array() actually looks like what it does.
>

Gibberish?? Probably a good time to go look up some php tutorials.
Apart from that, it's rather bad form as a missing index will create a
notice at the least. The isset snippet is better, though if you care
about finding null values you need to go the route of array_keys().

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] in_array - what the...

2010-06-25 Thread Bob McConnell
From: Daevid Vincent

> Why do this "in_array()" business??
> 
> Just do this...
> 
> if (self::$aboveArray[$name]) 
> {
>//something interesting here
> }

Does that gibberish actually do something? It doesn't make any sense to
me, while in_array() actually looks like what it does.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] in_array - what the...

2010-06-25 Thread Daevid Vincent

> -Original Message-
> From: Gary . [mailto:php-gene...@garydjones.name] 
> Sent: Friday, June 25, 2010 1:14 AM
> To: PHP
> Subject: Re: [PHP] in_array - what the...
> 
> "Ford, Mike" writes:
> >> -Original Message-
> >> If I have an array that looks like
> >>   array(1) {
> >> ["mac_address"]=>
> >> string(2) "td"
> >>   }
> >>
> >> and I call
> >>   if (in_array($name, self::$aboveArray))
> >> with $name as
> >>   string(11) "mac_address"
> >>
> >> what should be the result?
> >
> > FALSE -- in_array checks the *values*, not the keys, so would be
> > looking at the "td" for this element.
> 
> Agh! So it does.
> 
> You know what's worse? I even looked at the documentation of the
> function this morning wondering if that's what the problem was and
> *still* didn't see it!
> 
> *slinks away in embarrassment*

Why do this "in_array()" business??

Just do this...

if (self::$aboveArray[$name]) 
{
   //something interesting here
}


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] in_array - what the...

2010-06-25 Thread Ford, Mike
> -Original Message-
> From: Gary . [mailto:php-gene...@garydjones.name]
> Sent: 25 June 2010 09:14
> To: PHP
> Subject: Re: [PHP] in_array - what the...
> 
> "Ford, Mike" writes:
> >> -Original Message-
> >> If I have an array that looks like
> >>   array(1) {
> >> ["mac_address"]=>
> >> string(2) "td"
> >>   }
> >>
> >> and I call
> >>   if (in_array($name, self::$aboveArray))
> >> with $name as
> >>   string(11) "mac_address"
> >>
> >> what should be the result?
> >
> > FALSE -- in_array checks the *values*, not the keys, so would be
> > looking at the "td" for this element.
> 
> Agh! So it does.
> 
> You know what's worse? I even looked at the documentation of the
> function this morning wondering if that's what the problem was and
> *still* didn't see it!
> 
> *slinks away in embarrassment*

Not to worry -- happens to the best of us. (Been there, done that, got a 
wardrobe full of T-shirts!)

Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] in_array - what the...

2010-06-25 Thread Gary .
"Ford, Mike" writes:
>> -Original Message-
>> If I have an array that looks like
>>   array(1) {
>> ["mac_address"]=>
>> string(2) "td"
>>   }
>>
>> and I call
>>   if (in_array($name, self::$aboveArray))
>> with $name as
>>   string(11) "mac_address"
>>
>> what should be the result?
>
> FALSE -- in_array checks the *values*, not the keys, so would be
> looking at the "td" for this element.

Agh! So it does.

You know what's worse? I even looked at the documentation of the
function this morning wondering if that's what the problem was and
*still* didn't see it!

*slinks away in embarrassment*

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] in_array - what the...

2010-06-25 Thread Ford, Mike
> -Original Message-
> From: Gary . [mailto:php-gene...@garydjones.name]
> Sent: 25 June 2010 08:18
> To: PHP
> Subject: [PHP] in_array - what the...
> 
> If I have an array that looks like
>   array(1) {
> ["mac_address"]=>
> string(2) "td"
>   }
> 
> and I call
>   if (in_array($name, self::$aboveArray))
> with $name as
>   string(11) "mac_address"
> 
> what should be the result?

FALSE -- in_array checks the *values*, not the keys, so would be looking at the 
"td" for this element.

To do what you want to do, simply do an isset():

  if (isset($array['mac_address'])):
// do stuff with $array['mac_address']
  else:
// it doesn't exist
  endif;


Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] in_array - what the...

2010-06-25 Thread Gary .
If I have an array that looks like
  array(1) {
["mac_address"]=>
string(2) "td"
  }

and I call
  if (in_array($name, self::$aboveArray))
with $name as
  string(11) "mac_address"

what should be the result?

Because it is *false* and it is driving me nuts! This despite the fact
that if I do
  $foo = self::$aboveArray[$name];
$foo then has the value
  string(2) "td"

Am I not understanding what in_array does? Is there some bug in php that
has been present since 5.2.12 and still is? *bangs head against desk*

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] in_array breaks down for 0 as value

2008-11-21 Thread Stut

On 22 Nov 2008, at 00:06, Ashley Sheridan wrote:

On Fri, 2008-11-21 at 09:11 +, Stut wrote:

On 20 Nov 2008, at 23:09, Ashley Sheridan wrote:

On Thu, 2008-11-20 at 09:25 +, Stut wrote:

On 20 Nov 2008, at 06:55, Yashesh Bhatia wrote:
I wanted to use in_array to verify the results of a form  
submission

for a checkbox and found an interesting
behaviour.

$ php -v
PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37)
$

$ cat in_array2.php
 'page',
'story'  => 'story',
'nodereview' => 'abc',
);

if (in_array('page', $node_review_types)) {
print "page found in node_review_types\n";
}
if (in_array('nodereview', $node_review_types)) {
print "nodereview found in node_review_types\n";
}

?>
$ php in_array2.php
page found in node_review_types
$

This  works fine. but if i change the value of the key
'nodereview' to
0 it breaks down.

$ diff in_array2.php in_array3.php
6c6
<'nodereview' => 'abc',
---

'nodereview' => 0,

$

$ php in_array3.php
page found in node_review_types
nodereview found in node_review_types
$

Any reason why in_array is returning TRUE when one has a 0 value  
on

the array ?


That's weird, 5.2.6 does the same thing. There's actually a comment
about this on the in_array manual page from james dot ellis at  
gmail

dot com...



Be aware of oddities when dealing with 0 (zero) values in an  
array...


This script:


It seems in non strict mode, the 0 value in the array is evaluating
to
boolean FALSE and in_array returns TRUE. Use strict mode to work
around this peculiarity.
This only seems to occur when there is an integer 0 in the array. A
string '0' will return FALSE for the first test above (at least in
5.2.6).



So use strict mode and this problem will go away. Oh, and please  
read

the manual before asking a question in future.

-Stut

--
http://stut.net/

What about using the === and !== comparisons to compare and make  
sure

that 0 is not giving a false false.


That's effectively what using strict mode does. RTFM please.

-Stut


Hey, chill. If you offer advice, don't be so offensive to everyone.


I don't believe I was being offensive, you're clearly a very delicate  
little flower. The way I saw it you made a suggestion without  
understanding how to use the function in question. In my opinion RTFM  
is a perfectly reasonable response to that.


-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] in_array breaks down for 0 as value

2008-11-21 Thread Ashley Sheridan
On Fri, 2008-11-21 at 09:11 +, Stut wrote:
> On 20 Nov 2008, at 23:09, Ashley Sheridan wrote:
> > On Thu, 2008-11-20 at 09:25 +, Stut wrote:
> >> On 20 Nov 2008, at 06:55, Yashesh Bhatia wrote:
> >>> I wanted to use in_array to verify the results of a form submission
> >>> for a checkbox and found an interesting
> >>> behaviour.
> >>>
> >>> $ php -v
> >>> PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37)
> >>> $
> >>>
> >>> $ cat in_array2.php
> >>>  >>> $node_review_types = array(
> >>>  'page'   => 'page',
> >>>  'story'  => 'story',
> >>>  'nodereview' => 'abc',
> >>>  );
> >>>
> >>> if (in_array('page', $node_review_types)) {
> >>> print "page found in node_review_types\n";
> >>> }
> >>> if (in_array('nodereview', $node_review_types)) {
> >>> print "nodereview found in node_review_types\n";
> >>> }
> >>>
> >>> ?>
> >>> $ php in_array2.php
> >>> page found in node_review_types
> >>> $
> >>>
> >>> This  works fine. but if i change the value of the key  
> >>> 'nodereview' to
> >>> 0 it breaks down.
> >>>
> >>> $ diff in_array2.php in_array3.php
> >>> 6c6
> >>> <'nodereview' => 'abc',
> >>> ---
>   'nodereview' => 0,
> >>> $
> >>>
> >>> $ php in_array3.php
> >>> page found in node_review_types
> >>> nodereview found in node_review_types
> >>> $
> >>>
> >>> Any reason why in_array is returning TRUE when one has a 0 value on
> >>> the array ?
> >>
> >> That's weird, 5.2.6 does the same thing. There's actually a comment
> >> about this on the in_array manual page from james dot ellis at gmail
> >> dot com...
> >>
> >> 
> >>
> >> Be aware of oddities when dealing with 0 (zero) values in an array...
> >>
> >> This script:
> >>  >> $array = array('testing',0,'name');
> >> var_dump($array);
> >> //this will return true
> >> var_dump(in_array('foo', $array));
> >> //this will return false
> >> var_dump(in_array('foo', $array, TRUE));
> >> ?>
> >>
> >> It seems in non strict mode, the 0 value in the array is evaluating  
> >> to
> >> boolean FALSE and in_array returns TRUE. Use strict mode to work
> >> around this peculiarity.
> >> This only seems to occur when there is an integer 0 in the array. A
> >> string '0' will return FALSE for the first test above (at least in
> >> 5.2.6).
> >>
> >> 
> >>
> >> So use strict mode and this problem will go away. Oh, and please read
> >> the manual before asking a question in future.
> >>
> >> -Stut
> >>
> >> -- 
> >> http://stut.net/
> >>
> > What about using the === and !== comparisons to compare and make sure
> > that 0 is not giving a false false.
> 
> That's effectively what using strict mode does. RTFM please.
> 
> -Stut
> 
Hey, chill. If you offer advice, don't be so offensive to everyone.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] in_array breaks down for 0 as value

2008-11-21 Thread Stut

On 20 Nov 2008, at 23:09, Ashley Sheridan wrote:

On Thu, 2008-11-20 at 09:25 +, Stut wrote:

On 20 Nov 2008, at 06:55, Yashesh Bhatia wrote:

I wanted to use in_array to verify the results of a form submission
for a checkbox and found an interesting
behaviour.

$ php -v
PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37)
$

$ cat in_array2.php
 'page',
 'story'  => 'story',
 'nodereview' => 'abc',
 );

if (in_array('page', $node_review_types)) {
print "page found in node_review_types\n";
}
if (in_array('nodereview', $node_review_types)) {
print "nodereview found in node_review_types\n";
}

?>
$ php in_array2.php
page found in node_review_types
$

This  works fine. but if i change the value of the key  
'nodereview' to

0 it breaks down.

$ diff in_array2.php in_array3.php
6c6
<'nodereview' => 'abc',
---

 'nodereview' => 0,

$

$ php in_array3.php
page found in node_review_types
nodereview found in node_review_types
$

Any reason why in_array is returning TRUE when one has a 0 value on
the array ?


That's weird, 5.2.6 does the same thing. There's actually a comment
about this on the in_array manual page from james dot ellis at gmail
dot com...



Be aware of oddities when dealing with 0 (zero) values in an array...

This script:


It seems in non strict mode, the 0 value in the array is evaluating  
to

boolean FALSE and in_array returns TRUE. Use strict mode to work
around this peculiarity.
This only seems to occur when there is an integer 0 in the array. A
string '0' will return FALSE for the first test above (at least in
5.2.6).



So use strict mode and this problem will go away. Oh, and please read
the manual before asking a question in future.

-Stut

--
http://stut.net/


What about using the === and !== comparisons to compare and make sure
that 0 is not giving a false false.


That's effectively what using strict mode does. RTFM please.

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] in_array breaks down for 0 as value

2008-11-20 Thread Lars Torben Wilson
2008/11/20 Stut <[EMAIL PROTECTED]>:
> On 20 Nov 2008, at 06:55, Yashesh Bhatia wrote:
>>
>>  I wanted to use in_array to verify the results of a form submission
>> for a checkbox and found an interesting
>> behaviour.
>>
>> $ php -v
>> PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37)
>> $
>>
>> $ cat in_array2.php
>> > $node_review_types = array(
>>  'page'   => 'page',
>>  'story'  => 'story',
>>  'nodereview' => 'abc',
>>  );
>>
>> if (in_array('page', $node_review_types)) {
>>  print "page found in node_review_types\n";
>> }
>> if (in_array('nodereview', $node_review_types)) {
>>  print "nodereview found in node_review_types\n";
>> }
>>
>> ?>
>> $ php in_array2.php
>> page found in node_review_types
>> $
>>
>> This  works fine. but if i change the value of the key 'nodereview' to
>> 0 it breaks down.
>>
>> $ diff in_array2.php in_array3.php
>> 6c6
>> <'nodereview' => 'abc',
>> ---
>>>
>>>  'nodereview' => 0,
>>
>> $
>>
>> $ php in_array3.php
>> page found in node_review_types
>> nodereview found in node_review_types
>> $
>>
>> Any reason why in_array is returning TRUE when one has a 0 value on the
>> array ?
>
> That's weird, 5.2.6 does the same thing. There's actually a comment about
> this on the in_array manual page from james dot ellis at gmail dot com...
>
> 
>
> Be aware of oddities when dealing with 0 (zero) values in an array...
>
> This script:
>  $array = array('testing',0,'name');
> var_dump($array);
> //this will return true
> var_dump(in_array('foo', $array));
> //this will return false
> var_dump(in_array('foo', $array, TRUE));
> ?>
>
> It seems in non strict mode, the 0 value in the array is evaluating to
> boolean FALSE and in_array returns TRUE. Use strict mode to work around this
> peculiarity.
> This only seems to occur when there is an integer 0 in the array. A string
> '0' will return FALSE for the first test above (at least in 5.2.6).
>
> 
>
> So use strict mode and this problem will go away. Oh, and please read the
> manual before asking a question in future.
>
> -Stut

I wouldn't consider it weird; it's just how PHP handles loose type
comparisons. I would certainly agree that it's not terribly obvious
why it happens, though. :) That said, it's consistent with PHP
behaviour.

James Ellis almost got it right in his note. As I already noted, it's
not because of a conversion to boolean FALSE, but a conversion to
integer 0. You can test this by substituting FALSE for the 0 in the
array in the example and trying it.


Torben

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] in_array breaks down for 0 as value

2008-11-20 Thread Ashley Sheridan
On Thu, 2008-11-20 at 09:25 +, Stut wrote:
> On 20 Nov 2008, at 06:55, Yashesh Bhatia wrote:
> >  I wanted to use in_array to verify the results of a form submission
> > for a checkbox and found an interesting
> > behaviour.
> >
> > $ php -v
> > PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37)
> > $
> >
> > $ cat in_array2.php
> >  > $node_review_types = array(
> >   'page'   => 'page',
> >   'story'  => 'story',
> >   'nodereview' => 'abc',
> >   );
> >
> > if (in_array('page', $node_review_types)) {
> >  print "page found in node_review_types\n";
> > }
> > if (in_array('nodereview', $node_review_types)) {
> >  print "nodereview found in node_review_types\n";
> > }
> >
> > ?>
> > $ php in_array2.php
> > page found in node_review_types
> > $
> >
> > This  works fine. but if i change the value of the key 'nodereview' to
> > 0 it breaks down.
> >
> > $ diff in_array2.php in_array3.php
> > 6c6
> > <'nodereview' => 'abc',
> > ---
> >>   'nodereview' => 0,
> > $
> >
> > $ php in_array3.php
> > page found in node_review_types
> > nodereview found in node_review_types
> > $
> >
> > Any reason why in_array is returning TRUE when one has a 0 value on  
> > the array ?
> 
> That's weird, 5.2.6 does the same thing. There's actually a comment  
> about this on the in_array manual page from james dot ellis at gmail  
> dot com...
> 
> 
> 
> Be aware of oddities when dealing with 0 (zero) values in an array...
> 
> This script:
>  $array = array('testing',0,'name');
> var_dump($array);
> //this will return true
> var_dump(in_array('foo', $array));
> //this will return false
> var_dump(in_array('foo', $array, TRUE));
> ?>
> 
> It seems in non strict mode, the 0 value in the array is evaluating to  
> boolean FALSE and in_array returns TRUE. Use strict mode to work  
> around this peculiarity.
> This only seems to occur when there is an integer 0 in the array. A  
> string '0' will return FALSE for the first test above (at least in  
> 5.2.6).
> 
> 
> 
> So use strict mode and this problem will go away. Oh, and please read  
> the manual before asking a question in future.
> 
> -Stut
> 
> -- 
> http://stut.net/
> 
What about using the === and !== comparisons to compare and make sure
that 0 is not giving a false false.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] in_array breaks down for 0 as value

2008-11-20 Thread Stut

On 20 Nov 2008, at 06:55, Yashesh Bhatia wrote:

 I wanted to use in_array to verify the results of a form submission
for a checkbox and found an interesting
behaviour.

$ php -v
PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37)
$

$ cat in_array2.php
 'page',
  'story'  => 'story',
  'nodereview' => 'abc',
  );

if (in_array('page', $node_review_types)) {
 print "page found in node_review_types\n";
}
if (in_array('nodereview', $node_review_types)) {
 print "nodereview found in node_review_types\n";
}

?>
$ php in_array2.php
page found in node_review_types
$

This  works fine. but if i change the value of the key 'nodereview' to
0 it breaks down.

$ diff in_array2.php in_array3.php
6c6
<'nodereview' => 'abc',
---

  'nodereview' => 0,

$

$ php in_array3.php
page found in node_review_types
nodereview found in node_review_types
$

Any reason why in_array is returning TRUE when one has a 0 value on  
the array ?


That's weird, 5.2.6 does the same thing. There's actually a comment  
about this on the in_array manual page from james dot ellis at gmail  
dot com...




Be aware of oddities when dealing with 0 (zero) values in an array...

This script:


It seems in non strict mode, the 0 value in the array is evaluating to  
boolean FALSE and in_array returns TRUE. Use strict mode to work  
around this peculiarity.
This only seems to occur when there is an integer 0 in the array. A  
string '0' will return FALSE for the first test above (at least in  
5.2.6).




So use strict mode and this problem will go away. Oh, and please read  
the manual before asking a question in future.


-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] in_array breaks down for 0 as value

2008-11-19 Thread Lars Torben Wilson
2008/11/19 Yashesh Bhatia <[EMAIL PROTECTED]>:
> Hi.
>
>  I wanted to use in_array to verify the results of a form submission
> for a checkbox and found an interesting
> behaviour.
>
> $ php -v
> PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37)
> $
>
> $ cat in_array2.php
>  $node_review_types = array(
>   'page'   => 'page',
>   'story'  => 'story',
>   'nodereview' => 'abc',
>   );
>
> if (in_array('page', $node_review_types)) {
>  print "page found in node_review_types\n";
>  }
> if (in_array('nodereview', $node_review_types)) {
>  print "nodereview found in node_review_types\n";
>  }
>
> ?>
> $ php in_array2.php
> page found in node_review_types
> $
>
> This  works fine. but if i change the value of the key 'nodereview' to
> 0 it breaks down.
>
> $ diff in_array2.php in_array3.php
> 6c6
> <'nodereview' => 'abc',
> ---
>>'nodereview' => 0,
> $
>
> $ php in_array3.php
> page found in node_review_types
> nodereview found in node_review_types
> $
>
> Any reason why in_array is returning TRUE when one has a 0 value on the array 
> ?
>
> Thanks.

Hi Yasheed,

It looks like you've found the reason for the existence of the
optional third argument to in_array(): 'strict'. In your second
example (in_array3.php), what happens is that the value of
$node_review_types['nodereview'] is 0 (an integer), so it is compared
against the integer value of the first argument to in_array(), which
is also 0 (in PHP, the integer value of a string with no leading
numerals is 0). In other words, in_array() first looks at the first
element of $node_review_types and finds that it is a string, so it
compares that value as a string against the string value of its first
argument ('nodereview'). Same goes for the second element of
$node_review_types. However, when it comes time to check the third
element, in_array() sees that it is an integer (0) and thus compares
it against the integer value of 'nodereview' (also 0), and returns
true.

Make any sense? The problem goes away if you give a true value as the
third argument to in_array(): this tells it to check the elements of
the given array for type as well as value--i.e., it tells in_array()
to not automatically cast the value being searched for to the type of
the array element being checked.


Torben

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] in_array breaks down for 0 as value

2008-11-19 Thread Yashesh Bhatia
Hi.

  I wanted to use in_array to verify the results of a form submission
for a checkbox and found an interesting
behaviour.

$ php -v
PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37)
$

$ cat in_array2.php
 'page',
   'story'  => 'story',
   'nodereview' => 'abc',
   );

if (in_array('page', $node_review_types)) {
  print "page found in node_review_types\n";
 }
if (in_array('nodereview', $node_review_types)) {
  print "nodereview found in node_review_types\n";
 }

?>
$ php in_array2.php
page found in node_review_types
$

This  works fine. but if i change the value of the key 'nodereview' to
0 it breaks down.

$ diff in_array2.php in_array3.php
6c6
<'nodereview' => 'abc',
---
>'nodereview' => 0,
$

$ php in_array3.php
page found in node_review_types
nodereview found in node_review_types
$

Any reason why in_array is returning TRUE when one has a 0 value on the array ?

Thanks.

Yashesh

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] in_array() related problem

2006-11-05 Thread tamcy

Hi,

Thanks for your reply. After a sleep overnight I found I said
something really stupid. Arrays are compared in deep, and also for
objects. I really forgot the old PHP4 way and thought PHP5 compares
object simply by address when using ==, which is not the real case. I
need to use === for comparing objects of the same instance. And thanks
Tom for pointing out to use the strict parameter.


On 11/4/06, Richard Lynch <[EMAIL PROTECTED]> wrote:

> Try providing a custom comparison function.
>
> Almost for sure, PHP is attempting to "test" the == by a deeper scan
> than you think.
>
> On Fri, November 3, 2006 10:56 am, tamcy wrote:
> > Hello all,
> >
> > I'm new to this list. To not flooding the bug tracking system I hope
> > to clarify some of my understanding here.
> >
> > I am referring to the (now bogus) bug report
> > http://bugs.php.net/bug.php?id=39356&edit=2. This happens after my
> > upgrade to PHP 5.2, where the code shown produces a "Fatal error:
> > Nesting level too deep - recursive dependency?". Same testing code
> > reproduced below:
> >
> > 
> >  > class A
> > {
> >   public $b;
> > }
> >
> > class B
> > {
> >   public $a;
> > }
> >
> > $a = new A;
> > $b = new B;
> > $b->a = $a;
> > $a->b = $b;
> >
> > $test = array($a, $b);
> >
> > var_dump(in_array($a, $test));
> > 
> >
> > I think this is not rare for a child item to have knowledge about its
> > parent, forming a cross-reference.
> >
> > This code runs with no problem in PHP5.1.6, but not in 5.2. Ilia
> > kindly points out that "In php 5 objects are passed by reference, so
> > your code does in
> > fact create a circular dependency.". I know the passed by reference
> > rule. What I'm now puzzled is, why this should lead to an error.
> >
> > To my knowledge, despite the type-casting issue and actual algorithm,
> > in_array() should actually do nothing more than:
> >
> > function mimic_in_array($search, $list)
> > {
> >   foreach ($list as $item)
> > if ($search == $item)
> >   return true;
> >   return false;
> > }
> >
> > Which means:
> > 1. in_array() isn't multi-dimensional.
> > 2. in_array() doesn't care about the properties of any object.
> >
> > That is, I don't expect in_array() to nest through all available inner
> > arrays for a match, not to mention those are object properties, not
> > arrays.
> >
> > So here is the question: Why should in_array() throws such a "Fatal
> > error: Nesting level too deep" error? Why should it care? Is there any
> > behaviour I don't know?
> >
> > Thanks all in advance.
> >
> > Tamcy
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some starving artist.
> http://cdbaby.com/browse/from/lynch
> Yeah, I get a buck. So?
>
>



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] in_array() related problem

2006-11-04 Thread Tom Atkinson

Try like this:

var_dump(in_array($a, $test, true));


Richard Lynch wrote:

Try providing a custom comparison function.

Almost for sure, PHP is attempting to "test" the == by a deeper scan
than you think.

On Fri, November 3, 2006 10:56 am, tamcy wrote:

Hello all,

I'm new to this list. To not flooding the bug tracking system I hope
to clarify some of my understanding here.

I am referring to the (now bogus) bug report
http://bugs.php.net/bug.php?id=39356&edit=2. This happens after my
upgrade to PHP 5.2, where the code shown produces a "Fatal error:
Nesting level too deep - recursive dependency?". Same testing code
reproduced below:


a = $a;
$a->b = $b;

$test = array($a, $b);

var_dump(in_array($a, $test));


I think this is not rare for a child item to have knowledge about its
parent, forming a cross-reference.

This code runs with no problem in PHP5.1.6, but not in 5.2. Ilia
kindly points out that "In php 5 objects are passed by reference, so
your code does in
fact create a circular dependency.". I know the passed by reference
rule. What I'm now puzzled is, why this should lead to an error.

To my knowledge, despite the type-casting issue and actual algorithm,
in_array() should actually do nothing more than:

function mimic_in_array($search, $list)
{
  foreach ($list as $item)
if ($search == $item)
  return true;
  return false;
}

Which means:
1. in_array() isn't multi-dimensional.
2. in_array() doesn't care about the properties of any object.

That is, I don't expect in_array() to nest through all available inner
arrays for a match, not to mention those are object properties, not
arrays.

So here is the question: Why should in_array() throws such a "Fatal
error: Nesting level too deep" error? Why should it care? Is there any
behaviour I don't know?

Thanks all in advance.

Tamcy

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php







--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] in_array() related problem

2006-11-03 Thread Richard Lynch
Try providing a custom comparison function.

Almost for sure, PHP is attempting to "test" the == by a deeper scan
than you think.

On Fri, November 3, 2006 10:56 am, tamcy wrote:
> Hello all,
>
> I'm new to this list. To not flooding the bug tracking system I hope
> to clarify some of my understanding here.
>
> I am referring to the (now bogus) bug report
> http://bugs.php.net/bug.php?id=39356&edit=2. This happens after my
> upgrade to PHP 5.2, where the code shown produces a "Fatal error:
> Nesting level too deep - recursive dependency?". Same testing code
> reproduced below:
>
> 
>  class A
> {
>   public $b;
> }
>
> class B
> {
>   public $a;
> }
>
> $a = new A;
> $b = new B;
> $b->a = $a;
> $a->b = $b;
>
> $test = array($a, $b);
>
> var_dump(in_array($a, $test));
> 
>
> I think this is not rare for a child item to have knowledge about its
> parent, forming a cross-reference.
>
> This code runs with no problem in PHP5.1.6, but not in 5.2. Ilia
> kindly points out that "In php 5 objects are passed by reference, so
> your code does in
> fact create a circular dependency.". I know the passed by reference
> rule. What I'm now puzzled is, why this should lead to an error.
>
> To my knowledge, despite the type-casting issue and actual algorithm,
> in_array() should actually do nothing more than:
>
> function mimic_in_array($search, $list)
> {
>   foreach ($list as $item)
> if ($search == $item)
>   return true;
>   return false;
> }
>
> Which means:
> 1. in_array() isn't multi-dimensional.
> 2. in_array() doesn't care about the properties of any object.
>
> That is, I don't expect in_array() to nest through all available inner
> arrays for a match, not to mention those are object properties, not
> arrays.
>
> So here is the question: Why should in_array() throws such a "Fatal
> error: Nesting level too deep" error? Why should it care? Is there any
> behaviour I don't know?
>
> Thanks all in advance.
>
> Tamcy
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] in_array() related problem

2006-11-03 Thread tamcy

Hello all,

I'm new to this list. To not flooding the bug tracking system I hope
to clarify some of my understanding here.

I am referring to the (now bogus) bug report
http://bugs.php.net/bug.php?id=39356&edit=2. This happens after my
upgrade to PHP 5.2, where the code shown produces a "Fatal error:
Nesting level too deep - recursive dependency?". Same testing code
reproduced below:


a = $a;
$a->b = $b;

$test = array($a, $b);

var_dump(in_array($a, $test));


I think this is not rare for a child item to have knowledge about its
parent, forming a cross-reference.

This code runs with no problem in PHP5.1.6, but not in 5.2. Ilia
kindly points out that "In php 5 objects are passed by reference, so
your code does in
fact create a circular dependency.". I know the passed by reference
rule. What I'm now puzzled is, why this should lead to an error.

To my knowledge, despite the type-casting issue and actual algorithm,
in_array() should actually do nothing more than:

function mimic_in_array($search, $list)
{
 foreach ($list as $item)
   if ($search == $item)
 return true;
 return false;
}

Which means:
1. in_array() isn't multi-dimensional.
2. in_array() doesn't care about the properties of any object.

That is, I don't expect in_array() to nest through all available inner
arrays for a match, not to mention those are object properties, not
arrays.

So here is the question: Why should in_array() throws such a "Fatal
error: Nesting level too deep" error? Why should it care? Is there any
behaviour I don't know?

Thanks all in advance.

Tamcy

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] in_array and annidated path

2005-04-11 Thread kioto
Hi all sory for the double post but i have deleted the first email that 
i have send to the list.
The problem that i have found is that in_array function don't work with 
annidate path.
I have created a function that update a list of filepath from a 
directory to DB
but when i use particular path with space and more long like: 
C:\back\Microsoft.NET\Framework\v1.0.3705\file.exe
with more iteration there are problem because add the same file again.
Can you help me to fix the problem ? I have used this script
with CLI but to explain the problem i have added the source to this 
location:
http://www.fadelabot.net/update.php
Thanks so much to all and good work.
P.S: There is another problem about the CPU usage on windows Xp i have a 
process php.exe that use 99% of CPU.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] in_array w/statement

2004-12-16 Thread Sebastian
yeah, you're right though.. i had to use explode not implode

eg, if(in_array($uname['uid'], explode(' ', trim($userinfo['buddylist']
so i ditched the preg_split()

cheers.

- Original Message - 
From: "Jason Wong" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 16, 2004 3:39 PM
Subject: Re: [PHP] in_array w/statement


> On Friday 17 December 2004 02:33, Sebastian wrote:
>
> > I cannot solve this problem,. sorry if this looks confusing,.
>
> It is ...
>
> > i have a form and don't want to set the variable if the in_array is
true..
> > the code works, up until i add the last !$buddy in the statement, for
some
> > reason it seems to always be true, ... something i'm doing wrong? btw, i
> > cannot add the in_array to the statement because if the $buddylist is
empty
> > it will generate errors because of the empty implode.
> >
> > $buddylist = preg_split('/( )+/', trim($userinfo['buddylist']), -1,
> > PREG_SPLIT_NO_EMPTY);
>
> OK, it looks like $userinfo['buddylist'] is a string containing buddies
> separated by some whitespace:
>
>   'buddy1 buddy2'
>
> After the above statement $buddylist becomes an array.
>
> > if($buddylist)
> > {
> >  $buddy = in_array($uname['uid'], array(implode(',', $buddylist)));
> > }
>
> Here implode() returns a string containing 'buddy1,buddy2', then you stick
> that into an array() which is effectively:
>
>   array('buddy1,buddy2'); // note that there is only *1* element
>
> Now unless your $uname['uid'] really is literally 'buddy1,buddy2' then
$buddy
> will be false.
>
> Hope that's enough to get you going.
>
> -- 
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> --
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> --
> /*
> The moon is made of green cheese.
>   -- John Heywood
> */
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] in_array w/statement

2004-12-16 Thread Matt M.
> reason it seems to always be true, ... something i'm doing wrong? btw, i
> cannot add the in_array to the statement because if the $buddylist is empty
> it will generate errors because of the empty implode.

you could add the is_array() check.

> $buddylist = preg_split('/( )+/', trim($userinfo['buddylist']), -1,
> PREG_SPLIT_NO_EMPTY);
> 
> if($buddylist)
> {
>  $buddy = in_array($uname['uid'], array(implode(',', $buddylist)));
> }

not sure I understand this, implode returns a string, then you are
putting that string into the array() function.  I dont know what kind
of data you would get back from that.  $buddylist should already be an
array.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] in_array w/statement

2004-12-16 Thread Jason Wong
On Friday 17 December 2004 02:33, Sebastian wrote:

> I cannot solve this problem,. sorry if this looks confusing,.

It is ...

> i have a form and don't want to set the variable if the in_array is true..
> the code works, up until i add the last !$buddy in the statement, for some
> reason it seems to always be true, ... something i'm doing wrong? btw, i
> cannot add the in_array to the statement because if the $buddylist is empty
> it will generate errors because of the empty implode.
>
> $buddylist = preg_split('/( )+/', trim($userinfo['buddylist']), -1,
> PREG_SPLIT_NO_EMPTY);

OK, it looks like $userinfo['buddylist'] is a string containing buddies 
separated by some whitespace:

  'buddy1 buddy2'

After the above statement $buddylist becomes an array.

> if($buddylist)
> {
>  $buddy = in_array($uname['uid'], array(implode(',', $buddylist)));
> }

Here implode() returns a string containing 'buddy1,buddy2', then you stick 
that into an array() which is effectively:

  array('buddy1,buddy2'); // note that there is only *1* element

Now unless your $uname['uid'] really is literally 'buddy1,buddy2' then $buddy 
will be false.

Hope that's enough to get you going.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
The moon is made of green cheese.
  -- John Heywood
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] in_array w/statement

2004-12-16 Thread Sebastian
Hi,
I cannot solve this problem,. sorry if this looks confusing,.
i have a form and don't want to set the variable if the in_array is true..
the code works, up until i add the last !$buddy in the statement, for some
reason it seems to always be true, ... something i'm doing wrong? btw, i
cannot add the in_array to the statement because if the $buddylist is empty
it will generate errors because of the empty implode.

$buddylist = preg_split('/( )+/', trim($userinfo['buddylist']), -1,
PREG_SPLIT_NO_EMPTY);

if($buddylist)
{
 $buddy = in_array($uname['uid'], array(implode(',', $buddylist)));
}

if(($uname['uid'] == $ret) || ($uname['uname'] == $recipients2) &&
($uname['uid'] != 11) && !$buddy)
{
 $contactoptions = ''.$uname['uname'].'';
}
else if(($uname['uid'] != $bbuserinfo['userid']) && ($uname['uid'] != 11) &&
!$buddy)
{
 $contactoptions .= ''.$uname['uname'].'';
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] in_array not operating as 'expected'

2004-11-09 Thread Marek Kilimajer
Ing. Ivo F.A.C. Fokkema wrote:
Hi guys and gals,
I'm not screaming "Bug! Bug!" but this _does_ look 'illogical' to me. I've
searched the archives, but found no earlier conversation. Sorry if
I missed it. Consider the following code:
var_dump(in_array('test', array(0)));
What does this return? I expect bool(false), but it returns bool(true).
After some searching the web, I bumped into this:
http://www.phpdiscuss.com/article.php?id=67763&group=php.bugs
Basically, it is said by derick [at] php.net that this behavior is
expected. The following code :
var_dump('test' == 0);
'test' and 0 are not of the same type (string vs int), so string is 
converted to int, 0. In the examples below no type casting is needed.

also returns bool(true). But my logic tells me, that if 'test' == 0, then :
if (0) {
  ...
}
should do the same as 

if ('test') {
  ...
}
but it doesn't! The first if-statement is _not_ executed, the latter is.
In my opinion, this is not correct. Any thoughts on this? Am I not seeing
the logic here?
Thanks for your thoughts.
Ivo Fokkema
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] in_array not operating as 'expected'

2004-11-09 Thread Ing. Ivo F.A.C. Fokkema
Hi guys and gals,

I'm not screaming "Bug! Bug!" but this _does_ look 'illogical' to me. I've
searched the archives, but found no earlier conversation. Sorry if
I missed it. Consider the following code:

var_dump(in_array('test', array(0)));

What does this return? I expect bool(false), but it returns bool(true).
After some searching the web, I bumped into this:
http://www.phpdiscuss.com/article.php?id=67763&group=php.bugs

Basically, it is said by derick [at] php.net that this behavior is
expected. The following code :

var_dump('test' == 0);

also returns bool(true). But my logic tells me, that if 'test' == 0, then :

if (0) {
  ...
}

should do the same as 

if ('test') {
  ...
}

but it doesn't! The first if-statement is _not_ executed, the latter is.
In my opinion, this is not correct. Any thoughts on this? Am I not seeing
the logic here?

Thanks for your thoughts.

Ivo Fokkema

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] in_array()/finding page Problem

2003-10-23 Thread Marek Kilimajer
Ben G. McCullough wrote:

I agree - my solution is VERY resource intensive, but I think I may have 
over simplified my question.

Each item is listed by two categories, $medium and $period. Users can 
get to the item via a 'browse' of either category.  I want to user to be 
able to get back to the browse page they came from, or go to the other 
listing.
Pass current url to the next page, or only the relevant variables, then 
on the next page build the url from suplied variables.

To compound the issue - items are ordered by $sku, not $id.

So the select statement would look more like this:

SELECT COUNT(*)/12 FROM table WHERE medium = $medium ORDER BY $sku
You need to find out $sku of the current row and use

SELECT COUNT(*)/12 FROM table WHERE medium = $medium AND $sku <= 
$current_sku

But how would I find the page?

I had figured the only way was to actually go through each loop of pages 
looking for the $id, which is not working, and takes a lot of resources.

While this is only a test project, this issue is based on a real - world 
problem.

You solution is quite resource expensive. I would do:
[find $maxpages]
SELECT COUNT(*)/12 FROM table WHERE id <= $real_id;
list($maxpages) = fetch_row()
In result.php use "ORDER BY id"

Ben G. McCullough wrote:

I think I have a flaw of logic in trying to find the correct page in 
a mutli-page sql result.

Goal - find the correct page [results.php?page=x] when linking from 
another page.

Current method - loop through a pagination function looking for the 
matching $id in an array [simplified for illustration]:

[find $maxpages]
$page =1;
$catch=array();
while($page <= $maxpages) {
[set start #]
$result = [get sql results - limit  $startnumber, 12]
while($record = mysql_fetch_array($result)) {
extract($record);
$catch[] = $found_id;
}
if(in_array($real_id, $catch, TRUE)) {
$here = $page;
}
$page++;
}
echo "results.php?page=$here";

I never seem to get a "true" return on in_array(), and in testing, I 
don't seem to be getting a full result set with my look up.

I feel that I am missing something in the logic - or I am approaching 
this from the wrong direction.

I originally wanted to do the while test as "if in_array is FALSE, 
continue loop" but I couldn't get that to work at all.

Thank you for any help you can give this newbie.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] in_array()/finding page Problem

2003-10-23 Thread Marek Kilimajer
You solution is quite resource expensive. I would do:
[find $maxpages]
SELECT COUNT(*)/12 FROM table WHERE id <= $real_id;
list($maxpages) = fetch_row()
In result.php use "ORDER BY id"

Ben G. McCullough wrote:

I think I have a flaw of logic in trying to find the correct page in a 
mutli-page sql result.

Goal - find the correct page [results.php?page=x] when linking from 
another page.

Current method - loop through a pagination function looking for the 
matching $id in an array [simplified for illustration]:

[find $maxpages]
$page =1;
$catch=array();
while($page <= $maxpages) {
[set start #]
$result = [get sql results - limit  $startnumber, 12]
while($record = mysql_fetch_array($result)) {
extract($record);
$catch[] = $found_id;
}
if(in_array($real_id, $catch, TRUE)) {
$here = $page;
}
$page++;
}
echo "results.php?page=$here";

I never seem to get a "true" return on in_array(), and in testing, I 
don't seem to be getting a full result set with my look up.

I feel that I am missing something in the logic - or I am approaching 
this from the wrong direction.

I originally wanted to do the while test as "if in_array is FALSE, 
continue loop" but I couldn't get that to work at all.

Thank you for any help you can give this newbie.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] in_array()/finding page Problem

2003-10-23 Thread Ben G. McCullough
I think I have a flaw of logic in trying to find the correct page in 
a mutli-page sql result.

Goal - find the correct page [results.php?page=x] when linking from 
another page.

Current method - loop through a pagination function looking for the 
matching $id in an array [simplified for illustration]:

[find $maxpages]
$page =1;
$catch=array();
while($page <= $maxpages) {
[set start #]
$result = [get sql results - limit  $startnumber, 12]
while($record = mysql_fetch_array($result)) {
extract($record);
$catch[] = $found_id;
}
if(in_array($real_id, $catch, TRUE)) {
$here = $page;
}
$page++;
}
echo "results.php?page=$here";

I never seem to get a "true" return on in_array(), and in testing, I 
don't seem to be getting a full result set with my look up.

I feel that I am missing something in the logic - or I am approaching 
this from the wrong direction.

I originally wanted to do the while test as "if in_array is FALSE, 
continue loop" but I couldn't get that to work at all.

Thank you for any help you can give this newbie.

--

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] in_array

2002-08-22 Thread Riccardo Sepe

jochen schultz wrote:

> Hi Riccardo,
>
>  
>
>>   if(mysql_num_rows($rty->resu))  { //result
>>   $rec = mysql_fetch_array($rty->resu);
>>if(!isset($_SESSION["bkmks"]) ||   
>
>
> When you save something for the first time, the element of 
> $_SESSION["bkmks"] is a string and you can compare the array $rec with 
> this string.
>  
>
>> !in_array($rec, $_SESSION["bkmks"])) {
>>   
>
>
> Than you convert the element into an array  
>
>>   $_SESSION["bkmks"][] = $rec;
>>   
>
>
> and AFAIK in_array() can´t compare two arrays, correct me if i am 
> wrong...
>
>
> Greetings
> Jochen
>
>
>  
>
I think I've sorted it out  at least I know why it doesn't work:

bool in_array ( mixed needle, array haystack [, bool strict])
Searches haystack for needle and returns TRUE if it is found in the 
array, FALSE otherwise. If the third parameter strict is set to TRUE 
then the in_array() function will also check the types of the needle in 
the haystack. Note: If needle is a string, the comparison is done in a 
case-sensitive manner.
Note: In PHP versions before 4.2.0 needle was not allowed to be an array.
PHP on the server is 4.1.2 !!!

Is a foreach loop the only thing that I can do???

regards

Ricky






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] in_array()

2002-08-22 Thread jochen schultz


Hi Riccardo,

>if(mysql_num_rows($rty->resu))  { //result
>$rec = mysql_fetch_array($rty->resu);
> if(!isset($_SESSION["bkmks"]) ||

When you save something for the first time, the element of $_SESSION["bkmks"] is a 
string and you can compare the array $rec with this string.
>!in_array($rec, $_SESSION["bkmks"])) {

Than you convert the element into an array
>$_SESSION["bkmks"][] = $rec;

and AFAIK in_array() can´t compare two arrays, correct me if i am wrong...


Greetings

Jochen




*** REPLY SEPARATOR  ***

On 22.08.02 at 12:06 Riccardo Sepe wrote:

>Hi every1 I got this script that works fine on my local windows pc but
>on the remote server (FreeBSD)
>I get this message:
>
>Warning: Wrong datatype for first argument in call to in_array in
>/usr/local/..
>
>the script should bookmark an user choice storing it in the
>$_SESSION["bkmks"] array.
>this is the code:
>$rty->mark($id,$tab);   // call to the method
>that perform a standard query on the db
>if(mysql_num_rows($rty->resu))  { //result
>$rec = mysql_fetch_array($rty->resu);
> if(!isset($_SESSION["bkmks"]) ||
>!in_array($rec, $_SESSION["bkmks"])) {
>$_SESSION["bkmks"][] = $rec;
>
>when I store for the first time no problem ... When I try to store
>another item or the same item again
>I got that awful error
>
>thanks in advance !
>
>Ricky
>
>
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] in_array()

2002-08-22 Thread Riccardo Sepe

Hi every1 I got this script that works fine on my local windows pc but 
on the remote server (FreeBSD)
I get this message:

Warning: Wrong datatype for first argument in call to in_array in 
/usr/local/..

the script should bookmark an user choice storing it in the 
$_SESSION["bkmks"] array.
this is the code:
$rty->mark($id,$tab);   // call to the method 
that perform a standard query on the db
if(mysql_num_rows($rty->resu))  { //result
$rec = mysql_fetch_array($rty->resu);
 if(!isset($_SESSION["bkmks"]) || 
!in_array($rec, $_SESSION["bkmks"])) {
$_SESSION["bkmks"][] = $rec;

when I store for the first time no problem ... When I try to store 
another item or the same item again
I got that awful error

thanks in advance !

Ricky





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] in_array problems (another pair of eyes?)

2002-05-22 Thread Johnson, Kirk

Unless you are using PHP version 4.2 or higher, the first argument can't be
an array.

Kirk

> -Original Message-
> From: Jas [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 21, 2002 11:46 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] in_array problems (another pair of eyes?)
> 
> 
> I don't think I am using the syntax correctly, I have been 
> looking at this
> function on php.net and everything I have seen says my code should be
> working.
> A form allows the user to upload a file:
>  enctype="multipart/form-data">
>  
>  
>  
>  
> Resulting file (upload_done.php):
>  $types = array(".gif",
>   ".jpg",
>   ".jpeg",
>   ".htm",
>   ".pdf"); //place file type into array
> if (in_array(array ('.jpg', '.jpeg'), $types)) { //this is 
> the error line
> (line 7)
>  print "jpg file"; }
> ?>
> And here is my error:
> Warning: Wrong datatype for first argument in call to in_array in
> upload_done.php on line 7

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] in_array problems (another pair of eyes?)

2002-05-21 Thread Jason Wong

On Wednesday 22 May 2002 01:45, Jas wrote:
> I don't think I am using the syntax correctly, I have been looking at this
> function on php.net and everything I have seen says my code should be
> working.

What version of php are you using? In PHP versions before 4.2.0 needle was not 
allowed to be an array.

> if (in_array(array ('.jpg', '.jpeg'), $types)) { //this is the error line
> (line 7)
>  print "jpg file"; }
> ?>
> And here is my error:
> Warning: Wrong datatype for first argument in call to in_array in
> upload_done.php on line 7

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Punning is the worst vice, and there's no vice versa.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] in_array problems (another pair of eyes?)

2002-05-21 Thread Jas

I don't think I am using the syntax correctly, I have been looking at this
function on php.net and everything I have seen says my code should be
working.
A form allows the user to upload a file:

 
 
 
 
Resulting file (upload_done.php):

And here is my error:
Warning: Wrong datatype for first argument in call to in_array in
upload_done.php on line 7



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] in_array algorithm

2002-02-06 Thread Lars Torben Wilson

On Wed, 2002-02-06 at 08:26, John Fulton wrote:
> 
> Does anyone know which algorithm in_array() uses?  
> 
> For example, if I say
> 
> in_array("foo", $arr)
> 
> Does in_array() do an unordered sequential serach of $arr for 
> "foo" which takes up to n comparisons [where n = count($arr)],
> or does it do a binary search which takes about lg(n) comparisons?  
> Is it up to me to maintain a sorted array in the later case?  
> 
> Thanks,
>   John

Well, the source for the currect version of that function (as of
4.2.0-dev) is here:

 http://cvs.php.net/co.php/php4/ext/standard/array.c?r=1.156

Search down the page for 'php_search_array'--that's the function
which actually does the searching.

Looks like a simple sequential search to me. 


Torben


-- 
 Torben Wilson <[EMAIL PROTECTED]>
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] in_array algorithm

2002-02-06 Thread John Fulton


Does anyone know which algorithm in_array() uses?  

For example, if I say

in_array("foo", $arr)

Does in_array() do an unordered sequential serach of $arr for 
"foo" which takes up to n comparisons [where n = count($arr)],
or does it do a binary search which takes about lg(n) comparisons?  
Is it up to me to maintain a sorted array in the later case?  

Thanks,
  John



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] in_array error

2001-11-29 Thread Fred

You will not be able to use this and many other functions on a php3 only
machine.  For your convenience, all of the function references in the manual
state which versions of php support them and which do not.

Fred

Steve Osborne <[EMAIL PROTECTED]> wrote in message
008401c17916$dd87f200$[EMAIL PROTECTED]">news:008401c17916$dd87f200$[EMAIL PROTECTED]...
> I'm using php 4 on my machine, however the server that I am testing on
only
> supports php3
>
> - Original Message -
> From: "Gerard Onorato" <[EMAIL PROTECTED]>
> To: "Steve Osborne" <[EMAIL PROTECTED]>; "PHP-General
> (E-mail)" <[EMAIL PROTECTED]>
> Sent: Thursday, November 29, 2001 11:29 AM
> Subject: RE: [PHP] in_array error
>
>
> > Steve,
> >
> > What version of PHP are you running. in_array is >= 4.0. is_array was in
> 3.0
> > so this may be an issue for you.
> >
> > Gerard
> >
> > -Original Message-
> > From: Steve Osborne [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, November 29, 2001 3:08 PM
> > To: PHP-General (E-mail)
> > Subject: [PHP] in_array error
> >
> >
> > Can anyone explain why I am getting the following error?
> >
> > Fatal error: Call to unsupported or undefined function in_array() in
> > includes/chinlib21stCentury.inc on line 3131
> >
> >
> > Code:
> > if( (is_array($List)) AND (is_array($RemoveList)) )
> >  {
> >   $ListItems = count($List);
> >   sort($List);
> >   for($ListItem=0; $ListItem < $ListItems; $ListItem++)
> >   {
> >file://printf("List value: $List[$ListItem]\n");
> >if(!(in_array($List[$ListItem],$RemoveList)) AND
> (trim($List[$ListItem])
> > <> "") ) // Line 3131
> > $diff[] = $List[$ListItem];
> >   }
> >  }elseif($debugit){
> >   echo "In function ListDiff List and RemoveList are NOT arrays";
> >  }
> >  return ($diff);
> >
> >
> > Thanks,
> >
> > Steve Osborne
> > Database Programmer
> > Chinook Multimedia Inc.
> >
> >
> >
> > --
> > 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] in_array error

2001-11-29 Thread Steve Osborne

I'm using php 4 on my machine, however the server that I am testing on only
supports php3

- Original Message -
From: "Gerard Onorato" <[EMAIL PROTECTED]>
To: "Steve Osborne" <[EMAIL PROTECTED]>; "PHP-General
(E-mail)" <[EMAIL PROTECTED]>
Sent: Thursday, November 29, 2001 11:29 AM
Subject: RE: [PHP] in_array error


> Steve,
>
> What version of PHP are you running. in_array is >= 4.0. is_array was in
3.0
> so this may be an issue for you.
>
> Gerard
>
> -Original Message-
> From: Steve Osborne [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, November 29, 2001 3:08 PM
> To: PHP-General (E-mail)
> Subject: [PHP] in_array error
>
>
> Can anyone explain why I am getting the following error?
>
> Fatal error: Call to unsupported or undefined function in_array() in
> includes/chinlib21stCentury.inc on line 3131
>
>
> Code:
> if( (is_array($List)) AND (is_array($RemoveList)) )
>  {
>   $ListItems = count($List);
>   sort($List);
>   for($ListItem=0; $ListItem < $ListItems; $ListItem++)
>   {
>//printf("List value: $List[$ListItem]\n");
>if(!(in_array($List[$ListItem],$RemoveList)) AND
(trim($List[$ListItem])
> <> "") ) // Line 3131
> $diff[] = $List[$ListItem];
>   }
>  }elseif($debugit){
>   echo "In function ListDiff List and RemoveList are NOT arrays";
>  }
>  return ($diff);
>
>
> Thanks,
>
> Steve Osborne
> Database Programmer
> Chinook Multimedia Inc.
>
>
>
> --
> 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] in_array error

2001-11-29 Thread Gerard Onorato

Steve,

What version of PHP are you running. in_array is >= 4.0. is_array was in 3.0
so this may be an issue for you.

Gerard

-Original Message-
From: Steve Osborne [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 29, 2001 3:08 PM
To: PHP-General (E-mail)
Subject: [PHP] in_array error


Can anyone explain why I am getting the following error?

Fatal error: Call to unsupported or undefined function in_array() in
includes/chinlib21stCentury.inc on line 3131


Code:
if( (is_array($List)) AND (is_array($RemoveList)) )
 {
  $ListItems = count($List);
  sort($List);
  for($ListItem=0; $ListItem < $ListItems; $ListItem++)
  {
   //printf("List value: $List[$ListItem]\n");
   if(!(in_array($List[$ListItem],$RemoveList)) AND (trim($List[$ListItem])
<> "") ) // Line 3131
$diff[] = $List[$ListItem];
  }
 }elseif($debugit){
  echo "In function ListDiff List and RemoveList are NOT arrays";
 }
 return ($diff);


Thanks,

Steve Osborne
Database Programmer
Chinook Multimedia Inc.



--
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]




[PHP] in_array error

2001-11-29 Thread Steve Osborne

Can anyone explain why I am getting the following error?

Fatal error: Call to unsupported or undefined function in_array() in
includes/chinlib21stCentury.inc on line 3131


Code:
if( (is_array($List)) AND (is_array($RemoveList)) )
 {
  $ListItems = count($List);
  sort($List);
  for($ListItem=0; $ListItem < $ListItems; $ListItem++)
  {
   //printf("List value: $List[$ListItem]\n");
   if(!(in_array($List[$ListItem],$RemoveList)) AND (trim($List[$ListItem])
<> "") ) // Line 3131
$diff[] = $List[$ListItem];
  }
 }elseif($debugit){
  echo "In function ListDiff List and RemoveList are NOT arrays";
 }
 return ($diff);


Thanks,

Steve Osborne
Database Programmer
Chinook Multimedia Inc.



-- 
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] in_array

2001-09-13 Thread David Otton

On Thu, 13 Sep 2001 14:17:12 +0300, you wrote:

>i wrote php scripts with php 4. but my server's php version is php 3. i 
>used in_array function while i was writing the scripts. i used that 
>function to check posted variables is available or not.
>is there an another way to check this posted variables or another one 
>likes in_array function?

Straight from the manual:

http://www.php.net/manual/en/function.in-array.php

function in_array($needle,$haystack) { 
for($i=0; $ihttp://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] in_array

2001-09-13 Thread murat

hi,
i wrote php scripts with php 4. but my server's php version is php 3. i 
used in_array function while i was writing the scripts. i used that 
function to check posted variables is available or not.
is there an another way to check this posted variables or another one 
likes in_array function?

thanks


-- 
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] in_array() with associate array?

2001-07-31 Thread Brian White

in_array is for testing that a value exists in an array. What you want is

if ( isset( $some_array[some_key] ) )
print "HAS KEY";
else
print "DOESN'T HAVE KEY";


At 14:23 31/07/2001 -0400, Jaxon wrote:
>hi,
>
>in_array is confusing me :)
>
>can someone show me an example of how to test if
>
>$some_array[some_key]
>
>actually has a value, without outputting the value?
>
>tia,
>jaxon
>
>
>--
>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]

-
Brian White
Step Two Designs Pty Ltd - SGML, XML & HTML Consultancy
Phone: +612-93197901
Web:   http://www.steptwo.com.au/
Email: [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]




[PHP] in_array() with associate array?

2001-07-31 Thread Jaxon

hi,

in_array is confusing me :)

can someone show me an example of how to test if 

$some_array[some_key]

actually has a value, without outputting the value?

tia,
jaxon


-- 
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] in_array() function not supported on my server... anything else?

2001-04-26 Thread Maxim Maletsky

yeah.. the loop.

see php.net/arrays

most of the coolest array functions were introduced in PHP4

if you are trying to make a dynamic portable application you might want to
look into phpversion();

this will tell you which version it runs, and based on that will select the
best way to find the results on any server.


Sincerely, 

 Maxim Maletsky
 Founder, Chief Developer
 PHPBeginner.com (Where PHP Begins)
 [EMAIL PROTECTED]
 www.phpbeginner.com


 

-Original Message-
From: Richard [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 27, 2001 6:23 AM
To: [EMAIL PROTECTED]
Subject: [PHP] in_array() function not supported on my server...
anything else?


Greetings..

This is how I currently check for instances of words and other:

 for ($i=0; $i < $total_lines; $i++){
$line_array = explode("|",$line[$i]);


$swhat=strtolower($txtLinkname);
$xos =
array(strtolower($line_array[1]),strtolower($line_array[2]),strtolower($line
_array[3]),strtolower($line_array[4]),strtolower($line_array[5]));

if (in_array($swhat,$xos,true)) {
$found++;


Problem is, that the server where I have my files don't support in_array. It
is claimed that the servers PHP server is on version 4.0, how can this be
when in_array is a function that came first with PHP4  (according to my
documents) ??

Is there something else I could use?

Thanks
- Richard



-- 
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]




[PHP] in_array() function not supported on my server... anything else?

2001-04-26 Thread Richard

Greetings..

This is how I currently check for instances of words and other:

 for ($i=0; $i < $total_lines; $i++){
$line_array = explode("|",$line[$i]);


$swhat=strtolower($txtLinkname);
$xos =
array(strtolower($line_array[1]),strtolower($line_array[2]),strtolower($line
_array[3]),strtolower($line_array[4]),strtolower($line_array[5]));

if (in_array($swhat,$xos,true)) {
$found++;


Problem is, that the server where I have my files don't support in_array. It
is claimed that the servers PHP server is on version 4.0, how can this be
when in_array is a function that came first with PHP4  (according to my
documents) ??

Is there something else I could use?

Thanks
- Richard



-- 
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] in_array() with multidimensional array

2001-03-09 Thread Chris Lee

recusrion is your friend.

 $val)
  {
   if (is_array($val))
   {
if (in_multi_array($needle, $val))
 return 1;
   } else
if ($val == $needle)
 return 1;
  }
 }

 if (in_multi_array('d', $test))
  echo "TRUE \n";
 else
  echo "FALSE \n";

?>

-- 

 Chris Lee
 Mediawaveonline.com

 ph. 250.377.1095
 ph. 250.376.2690
 fx. 250.554.1120

 [EMAIL PROTECTED]


""Christian Dechery"" <[EMAIL PROTECTED]> wrote in message 
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
How can I check if a value is in a multidimensional array?

like I have

";
$produtos_sem_tracking[$i]['cod']=$idt[0];
$produtos_sem_tracking[$i]['idt']=$idt[1];
$produtos_sem_tracking[$i]['gen']=$idt[2];
}
?>

how can I check for an existing $produtos_sem_tracking['cod'] value for
example?


. [ Christian Dechery  ]
. Webdeveloper @ Tá Na Mesa!
. Listmaster @ Gaita-L
. http://www.tanamesa.com.br



-- 
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]




[PHP] in_array() with multidimensional array

2001-03-09 Thread Christian Dechery

How can I check if a value is in a multidimensional array?

like I have

";
$produtos_sem_tracking[$i]['cod']=$idt[0];
$produtos_sem_tracking[$i]['idt']=$idt[1];
$produtos_sem_tracking[$i]['gen']=$idt[2];
}
?>

how can I check for an existing $produtos_sem_tracking['cod'] value for
example?


. [ Christian Dechery  ]
. Webdeveloper @ Tá Na Mesa!
. Listmaster @ Gaita-L
. http://www.tanamesa.com.br



--
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]