Array Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Array Help

Post 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.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post 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 :)
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Post 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.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

well if you're calling it from the array then you should know which one you're calling :P
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Try looping through the array. isset will help you. Also look into some of the array functions such as array_pop
Post Reply