Re: [PHP-DEV] key_exists from php

2001-04-30 Thread Jon Parise
On Sun, Apr 29, 2001 at 09:50:13PM -0400, David Croft wrote: > There doesn't seem to be any way for a php script to determine whether a > given key exists in an array. isset($arr['x']) fails when it exists but > has a null value. I know there are ways around it like using foreach or > array_keys

Re: [PHP-DEV] key_exists from php

2001-04-30 Thread David Croft
Well my initial requirement was for class Result { ... function field($f) { #ifdef DEBUG assert(key_exists($f, $this->record)); #endif ... } } But more generally, IMHO something being set with a value of null is something different from it not being set at all. If that's not true,

Re: [PHP-DEV] key_exists from php

2001-04-30 Thread Zeev Suraski
Why? It's only interesting if you're trying to understand the table schema from one of the arrays. The right way to do it (IMHO) would be by querying the result using the field fetching functions... Zeev At 13:12 30/4/2001, David Croft wrote: >mysql_fetch_array (and probably others) return

Re: [PHP-DEV] key_exists from php

2001-04-30 Thread David Croft
mysql_fetch_array (and probably others) return a key with 'null' as the value if the field is null. This is distinct from that field not having been returned at all/not existing. -- |> /+\ \| | |> David Croft Infotrek On Mon, 30 Apr 2001, Zeev Suraski wrote: > Why would you care if a key exis

Re: [PHP-DEV] key_exists from php

2001-04-30 Thread Zeev Suraski
Why would you care if a key exists and is null? In general the behavior is so close to isset() that it's annoying to have to introduce a whole new function just for this difference. Zeev At 04:50 30/4/2001, David Croft wrote: >There doesn't seem to be any way for a php script to determine wh

Re: [PHP-DEV] key_exists from php

2001-04-29 Thread Andrei Zmievski
At 10:00 PM 4/29/01 -0400, David Croft wrote: >should that be separate e.g. index_exists? No, just have it take either string or number for a key. -Andrei -- PHP Development Mailing List To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PR

Re: [PHP-DEV] key_exists from php

2001-04-29 Thread David Croft
On Sun, 29 Apr 2001, Andrei Zmievski wrote: > Key may be a number as well. > > -Andrei should that be separate e.g. index_exists? -- |> /+\ \| | |> David Croft Infotrek -- PHP Development Mailing List To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands,

Re: [PHP-DEV] key_exists from php

2001-04-29 Thread Andrei Zmievski
At 09:50 PM 4/29/01 -0400, David Croft wrote: >There doesn't seem to be any way for a php script to determine whether a >given key exists in an array. isset($arr['x']) fails when it exists but >has a null value. I know there are ways around it like using foreach or >array_keys but these don't see

[PHP-DEV] key_exists from php

2001-04-29 Thread David Croft
There doesn't seem to be any way for a php script to determine whether a given key exists in an array. isset($arr['x']) fails when it exists but has a null value. I know there are ways around it like using foreach or array_keys but these don't seem very efficient. I would like to add a function