0

I have many input fields and I need to ascertain the first empty input field. at the moment I'm checking each one individually and if its not empty move on to the next one. But I was wondering if anyone knew of a more efficient way of doing this:

if(empty($a)){$a=$name;}else
if(empty($b)){$b=$name;}else
if(empty($c)){$c=$name;}else 

............if(empty($z)){$z=$name;}else

{$message="all boxes are filled"}; 
user1559811
  • 437
  • 3
  • 10
  • 26

1 Answers1

1

Well, assuming you're using POST or GET on the form you can just loop through each form element as such:

foreach ($_GET as $key => $value) { }
SeanWM
  • 16,789
  • 7
  • 51
  • 83