| We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
| PHP: Arrays and empty() | |
|---|---|
| Tweet Topic Started: Mar 25 2005, 03:16 AM (771 Views) | |
| FearKiller | Mar 25 2005, 03:16 AM Post #1 |
|
www.drewscripts.com
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I made a script that posts data from page1 to page2. Page1 has four variables that are set by checkboxes. Page2 has the following code on it to deal with these four variables in one array
Even if the user checks no boxes on page1, the array still shows up as not being empty on page2. If all the variables within the array are empty, then wouldn't the array itself be empty as well? What is in the array that is causing it to not be empty when none of the boxes are checked? |
![]() |
|
| Stefan | Mar 25 2005, 08:08 AM Post #2 |
![]()
Mew?
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
An array is empty when it contains no elements. If it contains elements, it isn't empty, regardless of those elements being empty or not. |
![]() |
|
| FearKiller | Mar 26 2005, 02:53 AM Post #3 |
|
www.drewscripts.com
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Oh, I see
That'll work. Thanks for your help. |
![]() |
|
| Seth | Mar 26 2005, 03:39 AM Post #4 |
|
I has a pony
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Nooooooooooooooooooo!
|
![]() |
|
| FearKiller | Mar 26 2005, 02:10 PM Post #5 |
|
www.drewscripts.com
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Hmm, that'll work to and looks much better, but shouldn't that last if statement read if($stillEmpty == "TRUE") rather than just if($stillEmpty) :unsure: |
![]() |
|
| Rory | Mar 26 2005, 03:16 PM Post #6 |
|
i;m a mess
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
nope. if($stillEmpty) checks whether $stillEmpty is TRUE or FALSE. If you want the condition to do something if false, then just do if(!$stillEmpty) You could do if($stillEmpty == TRUE) but the first method is easier. |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Technology Chat · Next Topic » |
| Track Topic · E-mail Topic |
6:26 PM Jul 11
|



![]](../../../../0/1/0/p601690/pipright.png)




6:26 PM Jul 11