General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old February 21st, 2003, 04:09 AM
johnn johnn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Southern California, USA
Posts: 48 johnn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Easy how to loop thru $_POST array?

Hi,

Suppose I have these $_POST variables after submit a form
$_POST['x']
$_POST['var1']
$_POST['var2']
$_POST['var3']
$_POST['var4']
$_POST['a']

Is there a simple way to loop thru to check only
$_POST['var1']
$_POST['var2']
$_POST['var3']
$_POST['var4']

to see if any of them is empty?
Thanks,
John

Reply With Quote
  #2  
Old February 21st, 2003, 06:46 AM
ZaireWeb ZaireWeb is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Hamburg, NY
Posts: 37 ZaireWeb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to ZaireWeb Send a message via AIM to ZaireWeb
PHP Code:
 $toCheck = array( 'var1''var2''var3''var4' );
$count    count$toCheck );
for( 
$i 0$i $count$i++ )
{
    if( 
$_POST[$toCheck[$i]] == '' )
    {
        echo 
$toCheck[$i] . ' was left empty';
    }



You could also use foreach, but I like for better ;P
__________________
Eric Coleman - Co-Owner ZaireWeb Solutions
eric.coleman@zaireweb.com
http://sitemod.net - sitemodCMS Coming Soon!

Reply With Quote
  #3  
Old February 21st, 2003, 07:47 AM
miraclemaker miraclemaker is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 1 miraclemaker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PHP Code:
 $toCheck = array( 'var1''var2''var3''var4' );
foreach( 
$_POST as $postvar )
{
****ifin_array($postvar,$toCheck ) && $postvar == "" )
********echo $toCheck[$i] . ' was left empty';


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Easy how to loop thru $_POST array?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway