Page 1 of 1

Array Help

Posted: Mon Mar 06, 2006 1:23 pm
by icesolid
Lets say I have an array of information being submitted and one of the array variables is inspector[].

How could I check to see if the array inspector[] is empty? As in nothing was submitted.

Posted: Mon Mar 06, 2006 2:47 pm
by hawleyjr
First you need a key so you cant just do inspector[] you need to do: inspector[0] or inspector['some_name']

Once you do that use the empty function :)

Posted: Mon Mar 06, 2006 3:12 pm
by icesolid
What if I don't know what inspector["dynamic_number"] is going to selected?

I can't just say:

if(empty($_POST["inspector"]["1"])

Because I don't know if inspector["1"] is being called from the array.

Posted: Mon Mar 06, 2006 3:36 pm
by s.dot
well if you're calling it from the array then you should know which one you're calling :P

Posted: Mon Mar 06, 2006 5:08 pm
by hawleyjr
Try looping through the array. isset will help you. Also look into some of the array functions such as array_pop