Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Derek Turner Newsgroups: comp.lang.php Subject: Looking for NULL in arrays Date: 25 Oct 2015 16:05:19 GMT Lines: 18 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net lOyysWHZa+exyQj7qTlHhACyrU/R2ZdrJzGDB8B1QRXgCZVe/6 Cancel-Lock: sha1:OqgU87NAUynasBdZoCeK4GFMpMs= User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Xref: csiph.com comp.lang.php:15779 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.