Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 3rd, 2003, 12:34 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default Array index


Hello friends,

  I am retrieving data from a table. I am using MySQL and PHP.
The query returns some records and stores in an array. If the query doesnt retrieve any record, array will not be created and displays an error on that line

foreach(arr1 as $ind=>&val)
{
}

but how can i find whether the array is created or not.
Is there any function to return lower bound and upper bound.

Thanx in advance

 
Old December 3rd, 2003, 02:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

isset() http://www.php.net/isset


You can also just create an empty array before you add things to it -- that way, foreach() doesn't produce an error. It simply does nothing since there are no elements to iterate over.


Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Index was outside the bounds of the array ECPcenter ASP.NET 1.0 and 1.1 Basics 3 July 5th, 2008 04:55 AM
xslt: pass index of array EefjeC XSLT 1 July 2nd, 2007 06:31 AM
Returning the Index number of an array prusila Java Basics 1 February 13th, 2007 05:54 AM
Index was outside the bounds of the array dba123 Reporting Services 0 March 6th, 2006 11:25 AM
index outside bounds of array error? barmanvarn BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 February 17th, 2005 03:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.