Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #1470

Re: evaluating a null value in an array

Date 2011-05-07 13:50 -0400
From bill <nobody@spamcop.net>
Newsgroups comp.lang.php
Subject Re: evaluating a null value in an array
References <5uWdnXAptq8EsVjQnZ2dnUVZ_sidnZ2d@cablespeedmi.com> <iq3asi$cn8$1@dont-email.me>
Message-ID <NLSdncSh7MTxG1jQnZ2dnUVZ_v-dnZ2d@cablespeedmi.com> (permalink)

Show all headers | View raw


On 5/7/2011 7:36 AM, Jerry Stuckle wrote:
> On 5/7/2011 7:27 AM, bill wrote:
>> I have an array of values, one of which might be null.
>>
>> This statement fails
>> if ( ($dos <= $insInfo[3]) or($dos == '0000-00-00'))
>>
>> with the error:
>> Notice: Undefined offset: 3 in
>> /var/www/MP2010-v2/classes/cDollar.php on
>> line 237
>>
>> when $insInfo[3] is NULL.
>>
>> I figured I could shortcut the evaluation with:
>>
>> if ( ( is_null($insInfo[3])) or($dos <= $insInfo[3]) or($dos ==
>> '0000-00-00'))
>>
>> but I get the same error.
>>
>> I sure would appreciate:
>> knowing why I get the error, and
>> a suggestion on how to evaluate this value.
>>
>> bill
>
> Is it null, or is it not set? There is a difference!
>
> Try isset() instead of is_null().

Exactly, when I use isset it does not error.
Thanks.

bill

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

evaluating a null value in an array bill <nobody@spamcop.net> - 2011-05-07 07:27 -0400
  Re: evaluating a null value in an array Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-07 07:36 -0400
    Re: evaluating a null value in an array Gregor Kofler <usenet@gregorkofler.com> - 2011-05-07 18:35 +0200
      Re: evaluating a null value in an array dougatmilmacdotcom@example.com (Doug Miller) - 2011-05-07 23:46 +0000
      Re: evaluating a null value in an array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-08 13:56 +0200
        Re: evaluating a null value in an array Gregor Kofler <usenet@gregorkofler.com> - 2011-05-08 20:18 +0200
    Re: evaluating a null value in an array bill <nobody@spamcop.net> - 2011-05-07 13:50 -0400
  Re: evaluating a null value in an array Denis McMahon <denis.m.f.mcmahon@gmail.com> - 2011-05-07 15:30 +0000
    Re: evaluating a null value in an array Gregor Kofler <usenet@gregorkofler.com> - 2011-05-07 18:34 +0200

csiph-web