If you want to use an array for you form, then here's one method
on you form page
<form ....>
*<input type="text" name="my_array[foo]" value="">
*<input type="text" name="my_array[bar]" value="">
<input type="text" name="my_array[blankable]" value="">
...
</form>
on you script page
<?
$mand = array("foo", "bar");
$cnt = count($mand);
for ($i = 0; $i < $cnt; $i++)
if (!in_array($mand[$i], $my_array))
echo "Error: You missed a required field - ".$mand[$i]."<br>\n";
?>
I haven't tested it though. Maybe you could use array_diff() ???
-----Original Message-----
From: Tom Ray [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 13, 2002 12:48 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Dynamic Arrays
I have an array question. I want to use a dynamic array but I don't know
how to do this. What I want to do is this, I want to write a form script
that takes the elements of the form and submits them in the array then I
want to do a loop and check to see if each element in the array has a
value and then if it does bullocks for them, but if it doesn't then I
want it to come to a screeching halt and tell them what dolts they are
for missing a field. So basically I want to have a Required field option
for the form. I'm still learning arrays and dynamic arrays are just
throwing me and I can't find a good code example to work from.
TIA.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php