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


Groups > comp.lang.php > #15779

Looking for NULL in arrays

From Derek Turner <frderek@suremail.je>
Newsgroups comp.lang.php
Subject Looking for NULL in arrays
Date 2015-10-25 16:05 +0000
Message-ID <d94ctvFn9f4U1@mid.individual.net> (permalink)

Show all headers | View raw


The problem is not that I don't know how to iterate through an array - 
the problem is that there are so many ways and I can't see the wood for 
the trees -which is the easiest method?

I have a simple array called $weeks. At the moment it contains either 
three string values or 5 could easily make it a consistent five if 
necessary.

$weeks[1] always contains a string. [2], [3] etc. either contain a string 
or NULL from mysql query.

I want to iterate through in key order until either [5] or a NULL value 
is found. What would do that, please? Is there a simple way without 
having to use an 'if' or similar test? I'm thinking something similar to

while ($row = $result->fetch_asoc());

that will detect a NULL value and stop. IYSWIM.

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


Thread

Looking for NULL in arrays Derek Turner <frderek@suremail.je> - 2015-10-25 16:05 +0000
  Re: Looking for NULL in arrays Derek Turner <frderek@suremail.je> - 2015-10-25 16:11 +0000
    Re: Looking for NULL in arrays Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-10-25 19:07 +0100
  Re: Looking for NULL in arrays Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-10-25 19:06 +0100
    Re: Looking for NULL in arrays Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2015-10-25 21:01 +0100
      Re: Looking for NULL in arrays Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-10-25 21:58 +0100
  Re: Looking for NULL in arrays Jerry Stuckle <jstucklex@attglobal.net> - 2015-10-25 16:33 -0400
    Re: Looking for NULL in arrays Derek Turner <frderek@suremail.je> - 2015-10-26 09:42 +0000
      Re: Looking for NULL in arrays Jerry Stuckle <jstucklex@attglobal.net> - 2015-10-26 09:45 -0400
        Re: Looking for NULL in arrays Derek Turner <frderek@suremail.je> - 2015-10-26 13:57 +0000
          Re: Looking for NULL in arrays Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-10-26 17:41 +0100
          Re: Looking for NULL in arrays Jerry Stuckle <jstucklex@attglobal.net> - 2015-10-26 12:49 -0400
      Re: Looking for NULL in arrays Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-10-26 22:25 +0100
  Re: Looking for NULL in arrays Denis McMahon <denismfmcmahon@gmail.com> - 2015-10-27 03:16 +0000
    Re: Looking for NULL in arrays Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-10-27 22:23 +0100

csiph-web